Jump to content

iwato

Members
  • Posts

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. OK. Please respond to the following question with this scenario in mind: either of the above two links is included in an email that is sent to a subscriber from the grammarcaptive.com domain. The information appended to the link is to be used by a third-party application located on the domain's server. QUESTION ONE: Would it be to safe to conclude that, when told that one has the option of using a query string or hash to send the information, the email must contain javascript that would parse the hash and send the information in an HTTP request separate from that generated upon clicking the link. QUESTION TWO: If the answer to Question One is in the affirmative. What would compel the developer of the third-party application to make such an option possible? Roddy
  2. PROBLEM: Please examine carefully to following two code block and focus specifically on the use of the # tag to as a key-value identifier. CASE ONE: <a href="https://www.grammarcaptive.com/overview.html#pk_campaign=Letter+No.+53">Learn more!</a> In the above example only a hash tag is used. In the following example both the hash tag and a query parameter are used. CASE TWO: <a href="https://www.grammarcaptive.com/overview.html?q=test#pk_campaign=Letter+No.+53&pk_kwd=Order+Now%21">Order now!</a> Although I can pretty well guess the meaning of the first example, I am completely baffled by the use of the second. QUESTION ONE: In the first example, does the # tag simply replace the query tag? In other words ?pk_campaign means the same as #pk_campaign. QUESTION TWO: If the # tag simply replaces the ? tag can you also write? #pk_campaign=Letter+No.+53&pk_kwd=Order+Now%21 QUESTION THREE: How does one interpret Case Two? Roddy
  3. Got it! So, I have been lucky in my own query string composition and did not know it. Roddy
  4. Yes, this is what I thought as well. So, why did you write The following portion of the above appears to contradict the examples just provided. Roddy
  5. If this were true, then what would allow me to send the following link in an email and have it returned by the user in tact and process ready. https://www.grammarcaptive.com/_utilities/php/email_verify.php?name=Lindsey%20Graham&email=kiusau@me.com&hash=$2y$10$yRg4Di9sKMYnAwq24pMya.4P7eTZctllMVpmctVGASc/siuvuUP5G&language=en&letter_no=1 Roddy p.s. Please excuse the recipient's name, but one does not always have control over who subscribes, and it is rare that one can ever truly know the subscriber's true motivation. Sometimes not even the subscriber knows.
  6. BACKGROUND: Working with Matomo has compelled me to dig deeper into the way that information gets passed over the internet. Up until now I have assumed that I can pass just about anything in a query string. In fact, this is exactly what I have been doing. What I am beginning to realize is that the PHP $_POST and $_GET variables have been doing work of which I was not aware. I have come to this conclusion with my new encounter of the encodeURI(), encodeURIComponent(), decodeURI(), and decodeURIComponent() functions. Indeed, I have read that no information can be passed in an HTTPRequest that is not in ASCII format. Is this true? QUESTION: Is it true that when working with PHP the values of PHP HTTPRequests are automatically URL encoded and URL decoded, and that when working with Javascript the same values must be manually encoded and decoded? Roddy
  7. JSG: But, you have set aside the very thing that I was trying to understand -- the jQuery ready( ) function. If I have understood this function correctly, it allows the Javascript contained within the function to be read as the rest of the page is being downloaded, but does not permit what is read to be executed until the rest of the page has been completed. My question, then: does the jQuery ready() function also insure that the Javascript thus read and loaded execute in the order that it is entered into the ready function? Roddy
  8. Revisiting the Matomo insert <!-- Matomo --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//{$PIWIK_URL}/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', {$IDSITE}]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> If what you said is true, then the following statement would be true would it not? STATEMENT: Were the same script to be entered twice on the same page, then the contents of the first completed _paq array would be passed onto the _paq array of the second entry and everything would be counted twice.
  9. Whether it is true or not, I have understood well what you explained. Under the assumption that what you have stated is true, could it not then be said that the jQuery ready( ) function behaves as if each line of script contained within the function were assigned its own script tag and defer attribute? Roddy
  10. iwato

    Array cloning

    Ingolme: I do not understand your reply. In the second example. If I change a, so too will b change, because the value of a.slice(0) is determined by the value of a. in the first example. can I not assign a new value to b without affecting the value of a? Roddy
  11. BACKGROUND: Earlier I posted a script from Matomo that serves as a counter for page hits and various other bits of information gleaned from a user's behavior on a webpage that bears the script. Although I now understand what the code does, I would like to understand its purpose. In particular, I would like to understand the probable reason for assigning to a variable another variable with the same name. The full code is given as: <!-- Matomo --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//{$PIWIK_URL}/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', {$IDSITE}]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> The code of interest is var _paq = _paq || []; I find this piece of code problematic for three reasons: It assumes that this variable could already exist, but I have no idea where it could come from. It it does already exist what happens to the pre-existent with the same name. How does it know which value to choose? Is there a latent selection mechanism that tells the assignment operator to choose the second value when the first is undefined? Please advise. Roddy
  12. OK. I have read through the MDN reference that you provided regarding the async and defer attributes. Comparing this reference against your statement and my own reflection it appears that Javascript and HTML are treated separately by a browser. This said, if no special action is taken Javascript will always be executed in the moment that it is read along with the other HTML tags in the document. Further, if I have understood correctly, there are three ways to introduce Javascript into a webpage: one, it is executed in the order that it is read along with other HTML tags; two, although read in the order in which it appears amont other HTML tags it need not need be executed at the time it is read; and three, although read in the order in which it appears among other HTML tags, it is not executed until all of the HTML tags have been loaded, and when read, it is read in the order in which it was introduced among the other HTML tags. In other words, 1) Javascript is synchronous when it is executed in the order that it appears along with the other HTML tags. 2) Javascript is asynchronous when the browser is not compelled to execute in the order that it appears among the other HTML tags 3) When the defer attribute is indicated and is assigned the value true, the corresponding script is treated as if it were contained in a jQuery ready() method and not executed until all other HTML tags have been read. QUESTION: Is the above a proper understanding of the relationship between HTML, Javascript, and browser behavior? Roddy
  13. Please find below the Javascript insertion <script> tag that Matomo uses to track user behavior on a webpage. <!-- Matomo --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//{$PIWIK_URL}/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', {$IDSITE}]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> I would like to clarify the meaning of the final line of the above function -- namely, g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); QUESTION ONE: Can the script attributes async and defer work indepedently of each another? What is the purpose of each and does their role change when they are imlpemented together? QUESTION TWO: Given the statement s=d.getElementsByTagName('script')[0]; does the statement s.parentNode.insertBefore(g,s); read: "Find the parent node of s and prepend g before s where s is the first node of all script nodes within the document including the node containing this function"?
  14. Although by no means fully recovered from a recent machine failure, I am back on the road in a much weakened condition. Please consider the following piece of code and correct me where my interpretation of the code is in error. <!-- Matomo --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//{$PIWIK_URL}/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', {$IDSITE}]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> My interpretation of same var _paq = _paq || []; _paq is an array that is initialized as empty or some preassigned value. _paq.push(['trackPageView']); Add a new element to _paq whose key-value pair is 'trackPageView' : undefined var u="//{$PIWIK_URL}/"; Create a variable called called u and assign to it the following string "// + some.domain.name + /". _paq.push(['setTrackerUrl', u+'piwik.php']); Add a new element to _paq whose key-value pair is 'setTrackerUrl' and u + piwik.php, respectively. var d=document, g=d.createElement('script'),s=d.getElementsByTagName('script')[0]; Create three variables named d, g and s whose values are d: the DOM document g: the name of a newly created element called 'script' s: an empty index array called 'script' g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); The resulting script tag should appear as follows: <script text='javascript' async='true' defer='true' src= 'u + piwik.js'></script> function()(); Run the function upon loading the document in which it is contained. Roddy
  15. The absence of error messages appears to have been created by improper coding errors of the like that creates a blank screen in PHP when you miss a comma, semi-colon, or quotation mark. The past two weeks have been a very painful learning experience for me, as it came just as I am approaching the peak of my first phase of site development. I have staked out a very mountainous range to climb, and it hurt to be so close and unable to reach my first peak on schedule. I unwisely allowed my hope to overshadow my past experience of disappointment, and was brutally frustrated as a result. In any case, a long trek around the first peak has allowed me to regain my strength and upward orientation, and I am back into climbing mode. Thank you, everyone for your effort. I apologize for putting you through my frustration. Hopefully I have learned well from my errors. Roddy
  16. Thank you, Dsonesuk, for your advice regarding a proper approach to take in remedying my problem of digital toilet paper. For the moment, however, I have solved the problem by rethinking how the paper functions in a smartphone environment where most people are likely to view Grammar Captive, anyway. The cost of implementation simply does not match the benefit of outcome at this early stage of development. I must move on toward production, and performance measurement must take priority over site appearance at this time. Roddy
  17. Unfortunately, the following did not work. $sql = "SELECT letter_no, letter_title, letter_abstract FROM sevengates_letter WHERE letter_no = ?"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $next_letter_no); $mysqli_stmt->execute(); $result = $mysqli_stmt->get_result(); $return = $result->fetch_all(MYSQLI_ASSOC); I have set it aside, however, for future consideration. I simple have no more time, if I am to meet my spring deadline for the commencement of podcast production. I have only two major tasks left -- both of which I suspect will be far smaller than they appear daunting. Thanks to you and others I now feel confident that I will be able to avoid many of the pitfalls into which I have fallen along the way. Have a great week! Roddy
  18. JSG: I have never used the fetch_all( ) method in this context -- only the fetch_assoc( ) method --, and it does not work in the context provided. Roddy
  19. JSG: For someone who is always asking for code, you are very reluctant to provide it. A simple example in the context of the class provided would be extremely helpful. Roddy
  20. JSG: Please select one of any of the provided class functions that contain "ordinary variables" and show me how you would declare them in the context of the class provided. davej: Why would you make the private and not public?
  21. Submit a CSS stylesheet with your work and insure that it is specific to the HTML elements of your document. Roddy
  22. You might wish to begin here. In regard to your button, you might try floating it or placing the entire bar in a flex box. Button and forms have a mind of their own. Roddy p.s. If you find my entry helpful, hover over the heart and click on the trophy.
  23. BACKGROUND: I am now running with PHP 5.5.38, and things are nearly back to normal. My error messages have returned, and things that once worked, now function well again. This said, I wish to make good on the pain and disappointment that I suffered and am requesting your help to do so. REQUEST: Please find below a PHP class that I created in order to gather data from my database. It works fine in my current PHP environment and produces the expected results. It has been upgraded to handle multiple languages and editions of the same letter number. In addition, I have included a list of suspect variables -- namely, variables whose undeclared status may have been a source of difficulty while running in my previous PHP 5.6.33 environment. class Newsletter { public $letter_no; public $letter_lang; public $mysqli_obj; public $letter_ed; public $pc_total; public $podcasts; public function __construct($letter_no, $letter_lang, $mysqli_obj, $letter_ed = 1) { $this->letter_no = $letter_no; $this->letter_lang = $letter_lang; $this->mysqli_obj = $mysqli_obj; $this->letter_ed = $letter_ed; } public function get_letter_data() { $sql = "SELECT letter.*, qa.* FROM sevengates_letter AS letter JOIN sevengates_qa AS qa ON letter.letter_no = qa.letter_no WHERE letter.letter_no = ? AND letter.letter_lang = ? ORDER BY letter.letter_ed DESC"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('is', $this->letter_no, $this->letter_lang); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $letter_results[$name] = $value; } } return $letter_results; } public function get_nextletter_data() { $next_letter_no = $this->letter_no + 1; $sql = "SELECT letter_no, letter_title, letter_abstract FROM sevengates_letter WHERE letter_no = ?"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $next_letter_no); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } $mysqli_stmt->free_result(); foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $nextletter_results[$name] = $value; } } return $nextletter_results; } public function get_podcasts() { $sql = "SELECT podcast_ref FROM sevengates_podref WHERE letter_no = ?"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $this->letter_no); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } $i = 1; foreach ($prelim_result as $arr) { foreach ($arr as $name => $value) { $name = $name . '_' . $i; $podcasts[$name] = $value; } $i++; } $this->pc_total = count($podcasts); return $podcasts; } public function get_podcasts_data($podcasts) { $this->podcasts = $podcasts; $prelim_result = []; $c = []; $row = []; $podcast_results = []; foreach ($podcasts as $name => $value) { $params = []; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $sql = "SELECT item_podtype, podcast_no_item, item_title, item_description, item_guid FROM rss2_podcast_item WHERE podcast_no_item = ?"; $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $value); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } } $prelim_result[] = $c; $mysqli_stmt->free_result(); } foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $pc_result[$name] = $value; } $podcast_results[] = $pc_result; } return $podcast_results; } public function get_pc_total() { return $this->pc_total; } } LIST OF SUSPECT VARIABLES $params = []; $prelim_result = []; $c = []; $letter_results = []; $next_letter_results = []; $row = []; $podcast_results = []; DISCUSSION I feel fairly comfortable with handling certain kinds of variables, but very uncomfortable handling others. In fact, I am not at all sure why the above class works, as it took a lot of guess work to make it function. Guess work is inefficient. QUESTION: How does one properly declare class variables that are not related to the arguments of the constructor function? Please provide examples from the list and code provided. Roddy
×
×
  • Create New...