Jump to content

iwato

Members
  • Posts

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. According to my host server, the internal server error is related to excess usage. This makes no sense, however, for no matter the time or day that I try to access these three files the result is always the same. More recently I tried to discover the file permissions for the troubled file, only to receive an internal server error for the file that was used to perform the investigation. Roddy
  2. Recently I created an experiment in order to obtain some insight into the source of the problem. Please find below the experiment, and its results. EXPERIMENT ONE (matomo_practice.html): https://www.grammarcaptive.com/_utilities/php/matomo_practice.html <p>'Can you see me?'</p> Result: Can you see me? ________________ EXPERIMENT TWO (matomo_practice_2.html): https://www.grammarcaptive.com/_utilities/php/matomo_practice_2.html <?php echo ('Can you see me?'); ?> Result: a blank page. _________________ EXPERIMENT THREE (matomo_practice.php): https://www.grammarcaptive.com/_utilities/php/matomo_practice.php <?php echo ('Can you see me?'); ?> Result: Internal Server Error. _________________ I sent these three link with the above information to Lunarpages (my host server), and they replied that I should correct my problem of excess usage. Well, 'my problem' of excess usage was addressed several weeks ago. Where before I was witnessing usage faults on the order of several and sometimes many 10s in a day, today you can count the total number of faults on one or two hands on any given day. As the above three links always behave in the same way, no matter when they are tried, it is highly unlikely that the problem is associated with excess usage. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Matomo - PHP Direct</title> <meta name="generator" content="BBEdit 10.5" /> </head> <body> ... The CONTENT OF THE THE THREE SEPARATE EXPERIEMENTS ... </body> </html> FURTHER NOTE: These three files are placed in a folder where the vast majority of PHP files on my website are stored. This problem does not appear to exist with the other files in the same folder. Roddy
  3. RAW HEADERS Host: www.grammarcaptive.com User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:48.0) Gecko/20100101 Firefox/48.0 Accept: application/json, text/javascript, */*; q=0.01 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate, br X-Requested-With: XMLHttpRequest Referer: https://www.grammarcaptive.com/overview.html Cookie: _pk_id.1.d6fd=b04f8c5a7bf9190d.1525557969.12.1526435670.1526435593.; _pk_ref.1.d6fd=%5B%22%22%2C%22%22%2C1526435593%2C%22http%3A%2F%2Flocalhost%2F~iwato%2Findex.html.en%22%5D; _pk_ses.1.d6fd=* Connection: keep-alive RESPONSE HEADERS Connection: close Content-Length: 556 Content-Type: text/html; charset=iso-8859-1 Date: Wed, 16 May 2018 01:54:58 GMT Server: Apache Might the problem lie in the fact that the request is over a secure connection and that cURL requires additional parameters? Roddy
  4. This is the error log configuration, but the log is empty. ini_set('log_errors', 1); ini_set('error_log', './error.log'); error_reporting(E_ALL); Roddy
  5. It is OK. I have since discovered what I hope to be is the proper Matomo get-method. Although the following code works when I query my host server from my local server, the same query fails when I upload the Javascript and PHP files to my host server and change the request URL to a directory path between add-on domains of the same host server. No matter what I try, I receive an Internal Server Error message. What follows is the code that both works and fails depending upon whether it resides on my local test server (suceeds) or on the page's online host server (fails). The AJAX $.ajax({ url: './_utilities/php/visitor_ip.php', dataType: 'JSON', statusCode: { 404: function() { alert( "Page not found" ); }}, success: function(visitor_ip) { $('#current_visitor_ip').html(visitor_ip.value); } }); The PHP <?php $url = 'https://.../matomo/index.php?module=API&method=API.getIpFromHeader&format=JSON&token_auth=...'; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true); echo (curl_exec($curl_request)); curl_close($curl_request); ?> I have since submitted a support ticket with my webhost server in an effort to clarify the problem. I believe it has to do with the communication between add-on domains. I have also been experimenting with an include statement and direct access to the PHP class that requests the method. So far, no luck. Roddy
  6. JSG: Although Matomo is a wonderful piece of software. For a beginner such as myself it is a dense impenetrable thicket that I cannot easily manipulate to satisfy certain special needs that the developer's of the softward did not think to address. When a visitor download's a webpage from a given domain the Matomo server is notified and assigns a visitor ID based upon a collection of information received from the HTTP Request. As I do not know how the Matomo visitor ID is created, I cannot accurately match the current user with the data stored about him in the Matomo database. There are two ways that I have discovered to access the data of a specific user: the visitor ID assigned by Matomo and the visitor's IP address. My objective is to know who is present so I know what to serve, and I have no idea how to obtain the visitor ID for a current visitor. Although I am working on it. Roddy
  7. Great. Now, how does one go about converting the URL into an IP address? What I truly need is the IP address. Even if I were to truncate everything after the domain name, how would I convert the domain name into a number like 64.102.73.1? Does Javascript have a function that will deliver up the IP address directly? Roddy
  8. BACKGROUND: A visitor arrives on a website. While still on the site he triggers an AJAX call that fills a <div> element with new HTML. Once the page is filled another AJAX call is made that seeks to read the following value as encoded JSON: $_SERVER['REMOTE_REFERER']. Instead I receive a 500 internal server error. The AJAX (function() { $("#main").html(''); $("<link/>", { rel: "stylesheet", type: "text/css", href: "./_utilities/css/yourprofile_filler.css" }).appendTo("head"); $.get('./yourprofile_filler.html', function(data) { $('#main').html(data); }).done(function(){ $.ajax({ url: './_utilities/php/visitor_ip.php', dataType: 'JSON', statusCode: { 404: function() { alert( "Page not found" ); }}, success: function(visitor_ip) { console.log(visitor_ip); } }); }); })(); The PHP <?php $referral_addr = $_SERVER['REMOTE_REFERER']; echo json_encode($referral_addr); ?> ERROR MESSAGE jquery.min.js:5 GET https://www.grammarcaptive.com/_utilities/php/visitor_ip.php 500 (Internal Server Error)send Is the $_SERVER variable not available in the moment of the AJAX? How do I otherwise make it available? Roddy
  9. I appear not to have understood clearly what you are suggesting. Alright. I will attempt to implement it, as I learn code best through experimentation. And, will return with the result. Roddy
  10. Place the following code as the first line of your while-statement and see what the array that you are fetching looks like. This might give you a clue to what is going on. print_r($row4); Also, I am not at all sure that enclosing the value of your WHERE statement in single quotes is necessary, or even correct. Notes from an experienced novice, Roddy
  11. Is there really no other way to use AJAX to achieve the task? This graphic imagery is designed to appear on my site's mainpage via HTML inserts called by AJAX. It is not until the insert is loaded with an initial set of images that visitor's will be given the opportunity to change what they see. Maybe I am over anticipating, but getting this to work via PHP appears without having to reload the entire mainpage appears impossible. No? Roddy
  12. Alright. So, I cannot do what I want in the way that I am trying to do it. However, I do not want to do it in either of the two ways that you are suggesting. My reasons are as follows. 1) The idea of the AJAX call is to allow users to change parameter values and sometimes even the parameter key-value pairs of the API call sent with the cURL to the Matomo server. In order for this to occur AJAX is a reasonable means of communication between the visitor's selection and the cURL that is sent. 2) In order to access the Matomo server an authorization token is required. I do not want this to be made visible to anyone and everyone. It must remain hidden -- hence, the introduction of the PHP file. 3) You appear to be suggesting a different file for each and every graph that I wish to appear on the same page. Any other suggestions? Roddy
  13. BACKGROUND: I am querying a MySQL database with a Matomo GUI. The API is called imageGraph. The call to the API works, as I have produced the desired image by assigning the URL as the value of an href attribute of an HTML <a> element. When using this link to display the image the image appears on a new page with its own header. This is not the effect that I desire. My goal is to display the image within a <div> tag on a webpage. The code that is suppose to achieve this latter effect is provided below. The URL that fetches the data from the API is identical for both the link and the PHP processing page for the AJAX call provided below. The PHP (./practice.php) $url ='https://.../matomo/index.php ?module=API &method=ImageGraph.get &idSite=1 &apiModule=Referrers &apiAction=getReferrerType &token_auth= ... &period=day &date=2018-04-10,2018-05-09'; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_exec($curl_request); curl_close($curl_request); The HTML <div id='referral_types'> <img src='' alt='Line Chart of Referral Types' /> </div> The Javascript $(document).ready(function() { $.ajax({ method: 'GET', url: "./practice.php", cache: false, contentType: 'image/png', success: function(response) { console.log(response); var graphic_src = response; $('#referral_types').find('img').attr('src', graphic_src); } }); }); EXPERIMENTATION: The console indicates that practice.php has been read, as it is filled with the kind of character nonsense typical of an image file. As the API permits an optional &format parameter I experimented with several including the following: AJAX PHP dataType JSON, &format=json dataType XML &format=xml (omit) &format=original The result was invariably the same. The ALT message with no image. Please advise. Roddy
  14. Never mind, I found the error. I had changed the name of the function, but because it is recursive, I needed to change the name of the function within the function as well. Hoorray! Hooray! Roddy
  15. BACKGROUND: I cannot find anything wrong with this function, but when I try to run it, PHP tells me that it is undefined. Thus, I suspect that the problem has to do with my version number. Where before I was running with 5.6, I am now running with 5.3. CODE function xmlobj_to_array($obj) { $namespace = $obj->getDocNamespaces(true); $namespace[NULL] = NULL; $children = array(); $attributes = array(); $name = strtolower((string)$obj->getName()); $text = trim((string)$obj); if( strlen($text) <= 0 ) { $text = NULL; } if(is_object($obj)) { foreach( $namespace as $ns=>$nsUrl ) { $objAttributes = $obj->attributes($ns, true); foreach( $objAttributes as $attributeName => $attributeValue ) { $attribName = strtolower(trim((string)$attributeName)); $attribVal = trim((string)$attributeValue); if (!empty($ns)) { $attribName = $ns . ':' . $attribName; } $attributes[$attribName] = $attribVal; } $objChildren = $obj->children($ns, true); foreach( $objChildren as $childName=>$child ) { $childName = strtolower((string)$childName); if( !empty($ns) ) { $childName = $ns.':'.$childName; } $children[$childName][] = xmlObjToArr($child); } } } return array( 'name'=>$name, 'text'=>$text, 'attributes'=>$attributes, 'children'=>$children ); } QUESTION: Please test the function and let me know whether it is my code or my version number. If it is the code, please suggest the appropriate changes. Roddy
  16. OK. I just reread what Ingolme wrote and would like to change the question Can it serve to send to HTTP Requests from the same page. 1) https://www.example.com/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday 2) Parse the hash on the same page on which the link resides and use Javascript to append it to another URL 3) https://www.otherURL.com/index.php??idSite=1&period=day&date=yesterday&category=Dashboard_Dashboard &subcategory=1
  17. JSG: OK. Item 3 is invalid. As you have just stated, however, all that is invalid is not dysfunctional. How is one to interpret the #? in https://www.example.com/index.php ?module=CoreHome &action=index &idSite=1 &period=day &date=yesterday #?idSite=1 &period=day &date=yesterday &category=Dashboard_Dashboard &subcategory=1 Can it function as a piggy-back ride on the original query that is parsed on arrival and added as a query string to a different URL? 1) https://www.example.com/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday 2) Parse the hash and append to otherpage.html 3) ./otherpage.html?idSite=1&period=day&date=yesterday&category=Dashboard_Dashboard &subcategory=1 Roddy
  18. OK. But what happens to the hash in Item 2? Is it a part of the query string? Or, does it refer to an anchor on the page to where the query string is sent? Or, is it something else altogether? Roddy
  19. BACKGROUND: I was recently introduced to the idea of using a hash as a means to transfer information in lieu of a query string in an HTTP request. Having thought that I understood the idea I was then introduced to the following query string: https://www.example.com/index.php ?module=CoreHome &action=index &idSite=1 &period=day &date=yesterday #?idSite=1 &period=day &date=yesterday &category=Dashboard_Dashboard &subcategory=1 I do not understand the user the expression ... #? ... From the point of view of parsing an HTTP request are the following two hash expressions treated the same? 1) https://www.example.com/index.php#blahblahblah 2) https://www.example.com/index.php?some_query_string#blahblahblah Accept for the order of parsing do items 2) and 3) achieve the same task? 3) https://www.example.com/index.php#blahblahblah?some_query_string Roddy ps: In which forum to questions about HTTP requests belong anyway?
  20. According to the manual using the hash in lieu of the query string is suppose to increase SEO. How this could occur in an email, however, is beyond me. The reason provided is as follows: whereas web-crawlers count the same URL with different hashes separately, the same URL with different query strings is counted the same. Do you agree? Roddy
  21. That might be the reason that I ask. Javascript is still a little foreign to me. I work much better with PHP. Roddy
  22. ADDENDUM: For what it is worth, I discovered the problem by working backward from a blank HTML file. The appearance of any addition <h3> element disrupts the procedure. QUESTION: How would you explain this? What would cause the script to fail in the presence of another <h3> tag? Roddy
  23. I realize this, but it is fairly complex. With your prompting I just eliminated the context and was able to make it work. For the moment this will have to be satisfactory. Thanks! Roddy
  24. I have no trouble making the code work in the Fiddle context either. It is when I take it out of context that it fails. Roddy
  25. I recently tried, on my own machine, to implement three code segments (HTML, CSS, and Javascript) that I found on Fiddler. What I thought would be a quick aside turned into well over an hour's worth of failed experimentation. Can you find anything wrong with the code that I was not able (click on Fiddler above). I do not like to leave unfinished work in defeat, but must move on. Matomo is just plain exciting! Roddy
×
×
  • Create New...