Jump to content

iwato

Members
  • Posts

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. OK. How do I get the value of podcastInsert is the same as $page->output(). The following obviously does not work.. <?php echo "<script> var podcastInsert = $page->output(); $('#main').html(podcastInsert); </script>"; ?>
  2. Is all of the Javascript executed again, only that which is included in and follows after the modified HTML tag, or only that contained in the modified tag? Does this rule hold for all HTML or only certain elements modified in certain ways? No, there is no other page unless you are referring to the page that contains the Javascript and is read into the HTML document when the page is downloaded. The hash is more important than the number. The hash is unique and unmistakable. Whereas the hash is generated automatically and is unique to each podcast, the podcast number is generated manually and can be mistaken. The hash is a better identifier.
  3. The Javascript code to which you appear to refer is that included in the <div id=#podcast_insert> ... </div> element indicated above. Under the assumption that you have correctly diagnosed the problem can you please help me to understand it just a little better by telling me where I am in error: Step 1: As PHP is the first thing to be processed, it inserts the following Javascript into the aforementioned <div> element when the conditions of the PHP if-statement are met. <script> var podcastInsert = $('#podcast_insert').html(); $('#main').html(podcastInsert); </script> Step: 2: The browser upon finding the Javascript replaces <div id='main'> element with the contents of the <div id='podcast_insert'> including the just mentioned Javascript. Step: 3: Having completed the insertion the browser finds a copy of the same Javascript that it just inserted and executes it again. What I do not understand is why it does not just continue down the page looking for more Javascript and stop at the bottom, if it does not find any? _____________ Where would you recommend placing the PHP script that inserts the aforementioned Javascript? After the code that fills the template? Namely, $page->replace_tags($tags); The reason that I ask this question is that the PHP statement $page->output(); Is what inserts the portion of the template to be displayed in the <div id='main'> element. I cannot just place it anywhere. Further, it should only be placed and then moved when there is something to place and move. Maybe I should just fill the <div id='main'> element directly. This, however, would require having to go up to the data base each time that the user wanted to return to the day's podcast. _____________ It is true that there is a <title> element in the PHP include that selects the portion of the template page to be inserted when the page->output( ) method is called, but why does this <title> element override the <title> element of the page into which the template is inserted? Understanding this and the above loop would likely help me greatly in my future programming needs. _____________ Finally, do you have any insight into why clicking on the text Today's Podcast No. 60 below the image does not produce the same smooth effect that clicking on the text Form, Use, and Meaning does? The code differs only in speed and destination. Everything occurs on the same page. Roddy
  4. OK. If you are still with me, I have uploaded what I have thus far achieved with your counsel and my own apparently ill-formed improvisation. i say this because I am receiving the following Javascript error message: "Range error: Maximum call stack exceeded". As I do not understand it, I do not know how to fix it. It is generated when the Proxy Link on the third-party proxy podcast hostage is selected. Although both of the following links will eventually take you to the same page, each link produces different results for the same page. The first link opens directly to the page with no HTTP Request, the second link opens to the same page with an HTTP Request. I have provided the PHP, HTML, and Javascript that controls the page. I suspect that the problem lies with the Javascript related to the HTML. Grammar Captive Podcast Hostpage: http://www.grammarcaptive.com/podcast_dev_copy.php Third-Party Proxy Podcast Hostpage: http://www.grammarcaptive.com/sender_proxy.php The link on the Third_Party Proxy Podcast Hostpage does result in consistent behavior. Should the resulting page appear incomplete click on the words "Today's Podcast No. 60" beneath the image. This is how the page is suppose to appear when you click on the proxy link on the proxy hostage. Also, please take note of, what is for me, the completely bizarre appearance of the <title> element of a PHP include file in your browser tab window -- namely, The get_string_between( )" Function. <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); /************************************************************************************************** Test whether an HTTP Request containing the hash and podcast_no key-value pairs has been received. **************************************************************************************************/ if (!empty($_GET['hash']) && !empty($_GET['podcast_no'])) { /************************************************************ Receive the guid and podcast number from a third party website, or during development from http://sun.local/~kiusau/reflexive/php_practice/projects/call_filler_and_display_page/sender.php *************************************************************/ $guid = filter_var($_GET['hash'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); $podcast_no = filter_var($_GET['podcast_no'], FILTER_SANITIZE_STRING, FILTER_VALIDATE_INT); /************************************************************ Clean the variables receivied and begin a session. *************************************************************/ session_start(); /************************************************************ Establish a connection with the database and set the character set. *************************************************************/ $host = "..."; $user = "..."; $pwd = "..."; $db = "..."; $mysqli_obj = new mysqli($host, $user, $pwd, $db); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } if (!$mysqli_obj->set_charset("utf8")) { printf("Error loading character set utf8: %s\n", $mysqli_obj->error); exit(); } /************************************************************ Retrieve and display the contents of the rss2_podcast_item data table *************************************************************/ $tbl_name = "rss2_podcast_item"; /************************************************************ Select and display the podcast number that corresponds to the matched guid *************************************************************/ $select_col = 'podcast_no_item'; $match_col = 'item_guid'; $sql_4 = "SELECT " . $select_col . " FROM " . $tbl_name . " WHERE " . $match_col . "=?"; $sql_stmt = $mysqli_obj->stmt_init(); $sql_stmt->prepare($sql_4); $match_col = $guid; $sql_stmt->bind_param("s", $match_col); $sql_stmt->execute(); $sql_stmt->bind_result($select_col); $sql_stmt->fetch(); /************************************************************ Create the variable list of item variables from which to retrieve data *************************************************************/ $select_arr['select_col1'] = 'podcast_no_item'; $select_arr['select_col2'] = 'item_title'; $select_arr['select_col3'] = 'item_link'; $select_arr['select_col4'] = 'item_description'; $select_arr['select_col5'] = 'item_author'; $select_arr['select_col6'] = 'item_pubdate'; $select_arr['select_col7'] = 'revision_date_item'; extract($select_arr); /************************************************************ Retrieve and Display the desired data from the matched item. *************************************************************/ $tbl_name = 'rss2_podcast_item'; $match_col = 'item_guid'; $sql_6 = "SELECT " . $select_col1 . "," . $select_col2 . "," . $select_col3 . "," . $select_col4 . "," . $select_col5 . "," . $select_col6 . "," . $select_col7 . " FROM " . $tbl_name . " WHERE " . $match_col . "=?"; $sql_stmt->prepare($sql_6); $match_col = $guid; $sql_stmt->bind_param("s", $match_col); $sql_stmt->execute(); $sql_stmt->bind_result($select_col1, $select_col2, $select_col3, $select_col4, $select_col5, $select_col6, $select_col7); $result_obj = $sql_stmt->get_result(); while ($row = $result_obj->fetch_assoc()) { foreach($row as $key => $value) { $row_results[$key] = $value; } $item_results = $row_results; } /************************************************************ Free the result object *************************************************************/ $result_obj->free(); /************************************************************ Retrieve and Display the desired data from the matched itunes item. *************************************************************/ $itunes_select_arr['select_col1'] = 'itunes_duration'; $itunes_select_arr['select_col2'] = 'itunes_summary'; $itunes_select_arr['select_col3'] = 'publish_date_itunes'; extract($itunes_select_arr,EXTR_PREFIX_IF_EXISTS,'itunes'); $tbl_name = 'rss2_podcast_itunes'; $itunes_match_col = 'podcast_no_itunes'; $sql_7 = "SELECT " . $itunes_select_col1 . "," . $itunes_select_col2 . "," . $itunes_select_col3 . " FROM " . $tbl_name . " WHERE " . $itunes_match_col . "=?"; $sql_stmt->prepare($sql_7); $match_col = $podcast_no; $sql_stmt->bind_param("s", $match_col); $sql_stmt->execute(); $sql_stmt->bind_result($itunes_select_col1, $itunes_select_col2, $itunes_select_col3); $itunes_results = array(); $itunes_result_obj = $sql_stmt->get_result(); while ($row = $itunes_result_obj->fetch_assoc()) { foreach($row as $key => $value) { $row_results[$key] = $value; } $itunes_results[] = $row_results; } /************************************************************ Free the result object *************************************************************/ $itunes_result_obj->free(); /************************************************************ Create the Session Variables and the $_SESSION Array *************************************************************/ $length = count($itunes_results); $publish_date_itunes = array(); if ($length > 1) { include '_utilities/php/most_recent_date_str.incl.php'; foreach($itunes_results as $key=>$arr) { $publish_date_itunes[] = $arr['publish_date_itunes']; } $most_recent_date = most_recent_date_str($publish_date_itunes); } else { $most_recent_date = $itunes_results[0]['publish_date_itunes']; } foreach ($itunes_results as $key => $arr) { if (strtotime($arr['publish_date_itunes']) === $most_recent_date) { // print_r($arr); // session_start(); $_SESSION = $arr; } } /***************************************************************************************************** Preparation for the Podcast Insert Using the BluePhoenix Template Engine ******************************************************************************************************/ require_once('./_utilities/php/page.php'); $template = './podcasting/template/template.html'; $start = "<div id='podcast_insert'>"; $end = "</div><!-- end div#podcast_insert -->"; $page = new Page($template, $start, $end); $tags = array( 'number' => $_SESSION['podcast_no_item'], 'title' => $_SESSION['item_title'], 'share' => $_SESSION['item_link'], 'description' => $_SESSION['item_description'], 'author' => $_SESSION['item_author'], 'date' => $_SESSION['item_pubdate'], 'revision' => $_SESSION['revision_date_item'], 'duration' => $_SESSION['itunes_duration'], 'summary' => $_SESSION['itunes_summary'] ); $page->replace_tags($tags); /***************************************************************************************************** Close If-Statement Whose Condition Tests for the Presence of $_GET['hash'] and $_GET['podcast_no'] ******************************************************************************************************/ } /************************************************************ Open to the Podcast Mainpage *************************************************************/ ?> <div id='podcast_insert'> <?php if((session_status() == 2) && isset($_SESSION['podcast_no_item'])) { $page->output(); echo "<script> var podcastInsert = $('#podcast_insert').html(); $('#main').html(podcastInsert); </script>"; }; ?> </div><!-- end div#podcast_insert --> /*********************************************************************************************** Today's Podcast Display and Refresh ***********************************************************************************************/ //Causes the weight of the font to change when the mouse passes over the text. $("#today").mouseover(function() { $(this).css({"cursor": "pointer", "font-weight":"800"}); }) .mouseout(function() { $(this).css("font-weight", "normal"); }); //Causes the weight of the font to change, displays the hidden text to appear in the #main <div> element, and brings about a change in color. $("#today").mouseover(function() { $(this).css({"cursor": "pointer", "font-weight":"800"}); }) .click(function() { var aboutContent = $("#podcast_insert").html(); $("#main").html(aboutContent); }) .mouseup(function() { $(this).css({"color": "#fadb9d","font-weight": "normal"}); $('body, html').animate({scrollTop: $('body').offset().top},1200); });
  5. This was not at all what I was expecting. What is more, I thought that the idea was to limit the number of calls to new pages. I will post something very soon of a very concrete nature, and we hopefully we begin afresh from there. Roddy
  6. Have you tried "./#name_of_tab"? ./ = same page # = some id attribute name_of_tab = the value of the id attribute For example, <div id='name_of_tab'> This is my tab contents. </div><!-- end div.#name_of_tab --> DISCLAIMER: I have never tried this, but if it works, why not? Roddy
  7. Is the following not a solution to your problem: https://www.w3schools.com/tags/att_button_formaction.asp Roddy
  8. BACKGROUND: I have some PHP code that I would like to turn on and off from two different approaches: on the one hand, via an HTTP Request from a third-party domain; and on the other hand, via the href attribute of an HTML <a> tag on the same page. Under normal circumstances one might write something like case one. I am proposing cases two and three. Third Party Domain HTTP Request (CASE ONE): Podcast No. 3 <a href='www.grammarcaptive.com?hash=2348dd8we23jrkajddu&podcast_no=003' title='Podcast Overview' target='_blank'>Overview</a> Same Page HTTP Request (CASE TWO): Podcast No. 3 <a href='#podcast_003?hash=2348dd8we23jrkajddu&podcast_no=003' title='Podcast Overview' target='_blank'>Overview</a> Same Page HTTP Request (CASE THREE): Podcast No. 3 <a href='./?hash=2348dd8we23jrkajddu&podcast_no=003' title='Podcast Overview' target='_blank'>Overview</a> QUESTION ONE: If neither case two, nor three is permissible, how would you suggest to achieve the same goal. If either or both cases two or three are possible, which is preferable and why?
  9. In answer to your response to the second quote: At present the podcast host page serves two separate functions. In the future it will be integrated into a protected membership forum with private access. Let us look more closely at the two functions: Firstly, it is a catalogue of podcasts. When the user arrives he may or may not be looking for a particular podcast. In fact, he may not even know what a podcast is. Should he decide to try one, the information related to the podcast (not the podcast) itself will appear in the main section of the page. This data must be retrieved from the data base in which it is stored. This information will be used by the user to decide whether he wants to download the podcast or not. Should he decide in the affirmative, he will be given a variety of alternative podcast host sites. Secondly, when the user finds a Grammar Captive podcast on a third party host page he is invited to investigate the selected podcast and other Grammar Captive podcasts further. To this end he is provided with a link containing an HTTP request for the selected podcast. When the Grammar Captive host page opens it will appear as if the user had selected the podcast from the host page. Thus, how the user opens to the page is important. Now, although it is likely that I can use the same code to retrieve and distribute the information from the database is needed, the way I access this code will surely be different. Although I have though a great deal about how to access and distribute the data in the second instance, I have thought very little about how to do it in the first. This is largely because I do not have any podcasts to work with, as of yet. If you have any ideas to bring these two function together in the most efficient way possible, please fire away! Roddy
  10. No, the user clicks on a third-party link with an HTTP request that is sent to the grammar captive.com domain. It is this request that tells the development page to fetch, process, create session variables, and redirect to the host page at www.grammarcaptive.com/podcasts_dev_copy.php. In the absence of this request the host page opens as you see it now, and the method for triggering access to the data base and the creation of the template will likely be different (see my final comment below). In effect, the decision is made by the avenue taken. If I do this, I would still have to implement the PHP header( ) function. What is more, each time the host page is opened, the question, "From where is the request coming?", would have to be answered. In the current, imagined set-up this question would never have to be asked, for the browser would always be told. You make a good point and have caused me to rethink my design strategy. Up until this point my focus has been on attracting the user to the Grammar Captive podcast host page and ultimately the Grammar Captive main page. As a result of this focus I have largely ignored the user whose avenue of approach is in the reverse direction -- namely, from the Grammar Captive main page to the podcast host page. For, such users will already be on the podcast host page when looking for additional information about a particular podcast. In effect, I will need two different triggers for generating the same template. Maybe I should have begun with this latter, easier problem first.
  11. Ouch! I just discovered that the jQuery load( ) function has been deprecated. Well, maybe not, apparently there were two load( ) | load( ) functions. Roddy
  12. Thanks! I just checked the jQuery webpage. The load( ) function accepts event handlers. This suggests the following procedure. 1) Receive the HTTP request from a remote 3rd party website. 2) Start a Session 3) Fetch and prepare the corresponding data from the site's database 4) Load the host page with the PHP header( ) function and location property and signal to the loading page with an accompanying session variable whether or not to load the insert. 5) Based upon the test decide whether to the host page should be loaded with the insert or not. 6) if the test indicates the presence of a third party request, execute a jQuery load() function with an event handler. 7) Use the event handler to trigger the template engine to create and download the filled template. 8) Enjoy! What do you think? Does it sound like a reasonable plan? Roddy .
  13. BACKGROUND: Please go to the following webpage and note four different ways to fill the center section. 1) The center section is loads with the rest of the page as the content of <div id='main'> 2) The center is replaced with hidden content already on the page using jQuery's html( ) function. (Click in the navigation panel on the phrase "Form, Use, and Meaning'.) 3) The center is replaced with a portion of content from another page using jQuery's load( ) function. (Click in the navigation panel on the phrase "Words, Phrases, and Clauses".) 4) The center will be replaced with its original content, but without having to reload the page. The principle is the same as in Item 2, but the link mechanism is different. (Click on the host's image.) DILEMMA: I want to fill the same section with an HTML-formatted template filled with information from a data base that opens simultaneously with the page. CONSTRAINTS: 1) The host page for the content -- namely, podcasts_dev_copy.php is structurally complete. Any changes that I make to it should be minor. 2) The content of the middle section must be filled invisibly before the host page opens, or it must fill simultaneously with the host page. RESOURCES: 1) I have developed a PHP page that takes information sent to it from a 3rd party HTTP request, downloads data from a database that is based on the request, and opens to the host page with a portion of the processed information using a $_SESSION superglobal and the PHP header( ) function and location property. (This page has not been posted.) 2) A template engine that generates the replacement content from the same $_SESSION superglobal Have you got any ideas? Roddy
  14. OK. Let's pause here while I engage in some implementation. I believe that I have sufficient grasp of the matter to produce something that can be useful to my users. Thank you for both your patience and assiduous insight. Roddy
  15. JSG: I would like to thank you for your kind response. It was very informative. It did, however, raise some new questions, and there were one or two points that still need clarification. Please consider the following and confirm or disconfirm each statement as before: 1) As each webpage is a different address the cookies associated with each page are different. Thus, during a session at least one setcookie() function must be called on each page where a call to the session_start() function is made? By the way, is this the way in which sessions are made secure with cookies? Or, is something additional required? 2) QUOTE: If a session ID is saved on a server, then it can be assumed that the session data related to that ID are also saved. JSG: That's kind of a weird statement. I'm not sure what the point is. I asked this question because I am unsure about the relationship between the session ID and the session data. The session ID appears to be an address for the session data on the one hand, and a means of communication between a browser and the server via cookies on the other. 3) There appear to be five, certainly three, different setting in the php.ini file that are related to time including session.cache_expire = 180 (The session data will continue to be available three minutes after the browser is closed.) session.cache_limiter = nocache session.cookie_lifetime = 0 (The cookie associated with the current session disappears when the session expires (see above)) session.entropy_length = 32 session.gc_maxlifetime = 1440 Could you also provide insight with regard to the other three? 4) QUOTE: The session ends when the browser is closed, or at least, all of the tabs with webpages containing the session_start() function are closed. JSG: The browser is supposed to delete the session cookie when it closes, because it is a temporary cookie. The session expires after a period of inactivity matching the PHP settings. This suggests that there are two kinds of cookies: session-related cookies and session non-related cookies. If the above is true, are there separate settings for each? Also, please make the following clear. Is it the closing of all pages that have called the session_start() function that closes the session, or is it only the closing of a browser that forces a session to end. 5) JSG: [T]he session_id function is not used to get session data, its only purpose, like the manual says, is to either get or set the current session ID. Yes, but is it not the getting of the session ID that makes the values of the session variables available?
  16. I did notice that session IDs are stored in the $_COOKIE superglobal when cookies are turned on. This suggested to me that Cookies and Sessions are used together. You have now provided me with an important use that explains why web masters often tell their users to leave cookies turned on. QUESTION: So, how is this done? I would very much like to have my users return to the last place they visited without having to log in. This is what I have understood. Please confirm or disconfirm each of the statements. 1) The session_start() function generates automatically a session ID that is stored on the server. 2) If a cookie is set, when a session is begun, the session data from a closed session can be retrieved via the session ID stored on both the user's machine and the server, but only if the session data are stored on the server. 3) If cookies are turned off, the session ID will not be stored on the user's machine, but it can be stored along with all of the session data on the server using the session_write_close() function. 4) If the session_write_close() is not employed the session data will be lost at the end of the session. 5) If a session ID is saved on a server, then it can be assumed that the session data related to that ID are also saved. 6) The session ends when the browser is closed, or at least, all of the tabs with webpages containing the session_start() function are closed. 7) If the session_write_close() function is employed, the value of the session variables just before the function is called can be retrieved via the session_id() function that was in use when the data was saved. However, only the last $_SESSION update is stored and retrievable unless manually set to do otherwise. Now, under the assumption that the user has cookies turned on, how does the browser know to invoke the proper session ID when the user returns to the same webpage. Is the latest session_ID automatically sent by the browser to the server? Or, must it be invoked to do so. If this latter is true, how is the transmission invoked? With regard to the security issue: under the assumption that session data are automatically destroyed with the close of each session, if they are not manually saved before the end of the session how could not employing cookies be less secure? Or, is it because the session data are automatically saved when a cookie is set?
  17. How is it that a cookie can be set in a browser, but the cookie is, itself, not on the same machine as the browser? Is a cookie not simply a name for special information that is passed between a remote server and a local browser? If so, how is it that this information cannot be found on the user's machine? If the session_save_path($path) function is called before the session_start() function, the session variables contained in the $_SESSION superglobal are surely retrievable. This I have done. But, ... 1) What happens when the user has cookies turned off (session.use_cookies = 0)? Does this mean that each time the session_start() function is called a new session_id is generated? 2) If item 1) is true, can one use the session_encode() function to transfer the information via a $_GET variable? Exactly how is this done? Roddy
  18. OK, if I have understood properly, ... 1) Cookies are stored on host server, but can be accessed by users via their web browsers. 2) I looked in the directory that houses my PHP application but could find nothing that resembles a place for stored session variables. Using the session_save_path() function I am able to direct their storage to a specific address and retrieve the information via the session name -- well, at least, I appear to have achieved this ability. I am not sure under what conditions it works and does not work. More importantly, I am not sure how to get this command to work on a third party's machine. Roddy
  19. It is the php.info option that I checked first. The session.cookie_path directive indicates local and master values of /. The session.save_path directive indicates no value for both the local and master settings. My session.cookie_lifetime option is set to 0 -- likely the default. Now, I know what a session.save_path file looks like in a directory, as I created two on the fly using the session_save_path() function. They always begin with the prefix "sess" -- for example, sess_n1kto7vp86c9nr8po7rl99im03. In contrast, I have never seen a cookie txt file and do not know what to look for. Am I correct to assume that the forward slash refers to the top level of my machine? Roddy
  20. Yes, the session.save_path directive is present, but in my configuration it is commented out. Still the information contained in the $_SESSION superglobal is being saved somewhere. How would you recommend that I discover where the information is kept. Running the session_save_path( ) function does not reveal the location. Also, please read this quote from W3Schools and then my original entry. My observation appears to contradict W3Schools. Can you explain why? Roddy
  21. It depends on how the session is specified and how the session is ended. If the session is user-defined, and the session is closed using the session_write_close( ) function, the session variables and their values remain for future use. How important are they? I am not sure yet and am still exploring as I always do when confronted with an extension that I have never used before. It is part of the learning experience. It started in Thailand way back in 2010, and I cannot rid myself of the habit. I like grammar! Roddy
  22. Thank you for responding. There is a lot having to do with sessions that is configured in php.ini, but a link to a text file that stores session data does not appear to be one of them. I just checked. Have you got any other ideas as to where the data is stored? Roddy
  23. BACKGROUND: Ever since I realized that the $_SESSION superglobal was the future of my podcast page (two-three days ago) I have been diligently exploring the PHP SESSION extension. It is amazing what I discovered. In particular, I am impressed by the tenacity of a user created session and the associated $_SESSION superglobal. Indeed, using the session_write_close( ) function one can not only close a browser window, quit one's browser, open the same page in a new browser, but one can also reboot one's machine, and still, the values of the session variables contained in the $_SESSION superglobal associated with the user_created session are in tact. QUESTION: To where does the session_write_close( ) function write such that it is forever saved, and how does one purge that location short of destroying the entire file, if the location's contents are not unique to the session whose data it is storing?
  24. iwato

    Please help a newbie

    Place the following code before you make your call to the mysqli_connect( ) function and see if it does not give you a better clue: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); Roddy
  25. <?=++$a?> <?=++$b?> <?=$private_id?> <?=session_id()?> I found this on the internet amongst some other code, and it appears to work. Unfortunately, I do not quite understand it. Is <?= a shorthand for <?php echo ... ;
×
×
  • Create New...