Jump to content

iwato

Members
  • Posts

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. Some new light has been shed on the problem! By sorting the gate categories and named events by gate number in the Visitor Profile / Splash Panel I have discovered that the files related to Gate Seven appear exclusively with those of Gate Two and that the data associated solely with gate7.html is missing. Roddy
  2. <?php ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log'); ini_set('html_errors', 0); ini_set('display_errors', 0); error_reporting(E_ALL); if (isset($_POST['methodName'])) { /***************************************************** The set_url_request() Function *****************************************************/ function set_url_request($method, array $params, $event_category) { $request = "method=" . $method; $segment_str = ''; if ($event_category == '') { foreach ($params as $param) { $request .= "&" . $param; } } else { (string) $segment_str = "segment=" . $event_category; array_push($params, $segment_str); foreach ($params as $param) { $request .= "&" . $param; } } return rawurlencode($request); } /***************************************************** Intialization of Key Variables *****************************************************/ $result = ''; $query_str = ''; $i = 0; $token_auth = '...'; $segment_str = ''; $categories = array(); $event_category = ''; $params = array(); /***************************************************** Event Segmentation *****************************************************/ if (isset($_POST['eventCategory'])) { foreach ($_POST['eventCategory'] as $event_category) { $event_category = filter_var($event_category, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH); $event_category = "eventCategory==" . $event_category; foreach ($_POST['methodName'] as $method) { $method = filter_var($method, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH); if ($method == '_getCategory') { $method = "Events." . substr($method, 1); $params = array("idSite=1","period=year","date=today","expanded=1"); $query_str = set_url_request($method, $params, $event_category); $sub_url .= "&urls[" . $i++ . "]=" . $query_str; } if ($method == '_getAction') { $method = "Events." . substr($method, 1); $params = array("idSite=1","period=year","date=today","expanded=1"); $query_str = set_url_request($method, $params, $event_category); $sub_url .= "&urls[" . $i++ . "]=" . $query_str; } if ($method == '_getName') { $method = "Events." . substr($method, 1); $params = array("idSite=1","period=year","date=today","expanded=1"); $query_str = set_url_request($method, $params, $event_category); $sub_url .= "&urls[" . $i++ . "]=" . $query_str; } } } $url = "https://...index.php"; $url .= "?module=API"; $url .= "&method=API.getBulkRequest"; $url .= "&format=json"; $url .= "&token_auth=$token_auth"; $url .= $sub_url; } // echo $url; /***************************************************** Send the Bulk Request *****************************************************/ $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true); $result = json_decode(curl_exec($curl_request)); if(curl_errno($curl_request)) { echo 'Curl error: ' . curl_error($curl_request); } curl_close($curl_request); /***************************************************** JSON Encode the Returned Request and Display It *****************************************************/ echo json_encode($result); } ?> Roddy
  3. If you can find something wrong with it I would be grateful. I can see nothing. I will even reproduce the value of the $url variable for you. https://.../index.php?module=API&method=API.getBulkRequest&format=json&token_auth=...&urls[0]=method%3DEvents.getCategory%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20One&urls[1]=method%3DEvents.getAction%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20One&urls[2]=method%3DEvents.getName%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20One&urls[3]=method%3DEvents.getCategory%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Two&urls[4]=method%3DEvents.getAction%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Two&urls[5]=method%3DEvents.getName%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Two&urls[6]=method%3DEvents.getCategory%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Three&urls[7]=method%3DEvents.getAction%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Three&urls[8]=method%3DEvents.getName%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Three&urls[9]=method%3DEvents.getCategory%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Four&urls[10]=method%3DEvents.getAction%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Four&urls[11]=method%3DEvents.getName%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Four&urls[12]=method%3DEvents.getCategory%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Five&urls[13]=method%3DEvents.getAction%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Five&urls[14]=method%3DEvents.getName%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Five&urls[15]=method%3DEvents.getCategory%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Six&urls[16]=method%3DEvents.getAction%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Six&urls[17]=method%3DEvents.getName%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Six&urls[18]=method%3DEvents.getCategory%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Seven&urls[19]=method%3DEvents.getAction%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Seven&urls[20]=method%3DEvents.getName%26idSite%3D1%26period%3Dyear%26date%3Dtoday%26expanded%3D1%26segment%3DeventCategory%3D%3DGate%20Seven Roddy
  4. BACKGROUND: It would be a long exercise in the grammar of the English language to explain what you can more readily understand by going directly to the relevant pages for which I provide the needed annotation below. gate7.html On this page you will find code that is identical in structure to six other pages similarly organized but with different content called gate1.html, gate2.html, gate3.html, gate4.html, gate5.html, gate6.html. The Javascript on this page and the other aforementioned pages performs two important functions: one, call a jQuery plug-in called $.colorbox that creates a gallery of iframes; and two, send an HTTP request to the Matomo application signalling a change of iframe. In addition, the gallery in question consists of four pages called gate7a.html, gate7b.html, gate7c.html, and gate7d.php. It should be noted that the other aforementioned six pages including gate1.html through gate6.html all perform similar tasks using nearly identical code. What makes gate7.html is the extension of the last iframe that it calls -- namely, gate7d.php. None of the other pages call an iframe with a PHP extension. overview.html After landing on this page you will find in the navigation bar on your left several options under the subheading Visitor Profile. I would like to draw your attention to two of them -- namely, Event Profiles and Splash Panel. These two panels report similar information obtained from the Matomo database -- albeit via differently constructed PHP cURL calls. Event Profiles: Once the panel fills, click anywhere where it says by Category and what will appear is an entry for all of the seven gates, but the one in question. Splash Panel: Click on any of the items under the heading By Category, and you will discover the same. The absence of data for the Gate Seven gallery. Click on any of the items under the heading By Named Event, and you will discover that the Javascript for Matomo is collecting the desired data. Indeed, you will find listed gate7a, gate7d, and title 7; all of these pages are tracked with the same category tag -- namely, Gate Seven. CAUTION: The Matomo application is extremely slow in my current server environment. You must be patient for the data to fill. Soon, I will have upgraded to a scalable cloud with my own dedicated IP address, and this problem is expected to go away. Also, note that the splash panel consists of some 47 individually constructed webpages eight of which contain Javascript using the same $.colorbox plug-in. INSTRUCTION: After you load the overview.html page open your web console. Then, click on the heading Splash Panel under Visitor Profile, open your Network tab in your web console, and look for a file called sevengates_splashpanel.php. Check the AJAX parameters sent to this page and notice that Gate Seven is among them. Then, check the pages Response section and notice the format of the 21 returned items. The pattern object, object, array occurs six times. For the last three items -- what should contain the information from Gate Seven -- are three empty arrays. QUESTION: How would you explain the aforementioned anomaly of three empty arrays? Roddy
  5. BACKGROUND: I would like to insert a jQuery UI widget into my code. In order to make the widget work, however, it appears to require a more recent version of jQuery. Should I implement the widget, the HTML in which it resides, the controlling Javascript including the new version of jQuery, as well as the CSS would all be called dynamically when the widget is inserted. My concern is that the new inserted version of jQuery might interfere with the rest of the page not included in the insert. QUESTION: Do I have reason to be concerned? Please explain your answer.
  6. So, the following statement is true. Is this not correct? Roddy
  7. BACKGROUND: Having recently learned about localStorage and familiarized myself with its methods I would now like to apply it as suggested by one of W3Schools' mentors for the purpose of identifying return visitors. Searching on the internet turned up little that was very satisfying. QUESTION: Is there a standard routine for identifying return visitors or must I develop my own? Roddy
  8. I believe we were talking past one another. Please compare the following two pieces of code and explain why the variable refer_type works and the variable cookie_set fails. Is it because the else-statement is creating a default value? The PHP if (isset($_GET['refer_type']) && filter_var($_GET['refer_type'], FILTER_VALIDATE_INT)) { $refer_type = $_GET['refer_type']; } else { $refer_type = 0; } if (isset($_COOKIE['_pk_id_1_28d8'])) { $cookie_set = 1; } The Javascript var refer_type = <?php echo $refer_type;?>; var cookie_set = <?php echo $cookie_set;?>; Roddy
  9. Hooray! Hooray! I can now make Matomo bulk requests. I fixed the problem by separating out the index variable ($i). $url .= "&urls[" . $i++ . "]=" . $query_str; Roddy
  10. REQUEST: Please compare the following PHP code with the intended result, and if possible, say why only the last urls[ ] parameter is being read. BACKGROUND: The following code is part of a successfully received and partially processed HTTP POST Bulk Request to the Matomo application. Both of the called methods -- namely, Events.getCategory and Events.getAction -- have been tested separately and are perfectly functional. Further, the Matomo application reports no dysfunction, and there are no warning, notices or other indicated sources of foul coding in the PHP log file. $result = ''; $query_str = ''; $i = 0; $token_auth = '...'; function set_url_request($method, $params) { $request = "method=$method"; foreach ($params as $param) { $request .= "&" . $param; } return rawurlencode($request); } $url = "https:/.../index.php"; $url .= "?module=API"; $url .= "&method=API.getBulkRequest"; $url .= "&format=json"; $url .= "&token_auth=$token_auth"; foreach ($_POST['methodName'] as $method) { $method = filter_var($method, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH); if ($method == '_getCategory') { $method = "Events." . substr($method, 1); $params = array("idSite=1","period=year","date=today","format=json"); $query_str = set_url_request($method, $params); $url .= "&urls[$i++]=" . $query_str; } if ($method == '_getAction') { $method = "Events." . substr($method, 1); $params = array("idSite=1","period=year","date=today","format=json"); $query_str = set_url_request($method, $params); $url .= "&urls[$i++]=" . $query_str; } } The above is suppose to yield code formatted in a manner similar to the following HTTP request. Obviously, I have modified it in important ways, Important, however, is that the &urls[0] request appears to be ignored. https://demo.piwik.org/index.php ?module=API &method=API.getBulkRequest &format=json &urls[0]= method%3dVisitsSummary.get %26idSite%3d3 %26date%3d2012-03-06 %26period%3dday &urls[1]= method%3dVisitorInterest.getNumberOfVisitsPerVisitDuration %26idSite%3d3 %26date%3d2012-03-06 %26period%3dday Roddy
  11. Why is it that you believe that I did not give cookie_set a default value? Are you suggesting with the following that I set two cookies: one with Matomo and one directly with PHP? For the moment, a local test environment that would be all convenient is impossible. I agree with you; it is generally foolish to depend on a third party service to control my site, but in this case the third party service is on my host server. It belongs to me. Roddy
  12. Without looking at the page and under the assumption that you are using an HTML form element to collect the consumer's preferences for the type of pizza that he wishes to purchase, perform the calculation with PHP at the top of the page and send the data used to make the calculation to the script via the form element on the same page. To send the data to the PHP script configure your form element as follows. Note especially the values of the method and action statements. <form id="pizza_data" method="post" name="pizza_data" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>"> And, enclose the PHP script that performs the calculation in the following if-statement. if ($_SERVER["REQUEST_METHOD"] == "POST") { [script that performs the calculation] } Once the calculation has been completed copy it to a Javascript variable, and then replace the form submit button with the resulting price. Alternatively, display it elsewhere on the same page and leave the submit button in tact. <script> var total_price = <?php echo $total_price;?>; </script> Roddy
  13. OBJECTIVE: Suppress my site's splash panel for repeat visitors using a mechanism similar to the one that I use to suppress the panel for visitors whose viewports are too small to handle it properly. BACKGROUND: As I have instructed Matomo not to recognize me when I access the application I have no way of testing whether my code is working. According to a friend who has experimented with his own computer it does not. Although I am able to retrieve the cookie set by Matomo, I am now uncertain about how to handle it. NOTE: The cookie that Matomo appears to set is not set until the page has The COOKIE Sent by Matomo Array ( [_pk_id_1_28d8] => b1dccabc0123a611.1529214805.24.1530731060.1530731060. [_pk_ses_1_28d8] => * ) The PHP that Recovers the COOKIE and Assigns It to a Javascript Variable if (isset($_COOKIE['_pk_id_1_28d8'])) { $cookie_set = 1; } The JAVASCRIPT on the Same Page as the PHP var cookie_set = <?php echo $cookie_set;?>; The JAVASCRIPT on a Loaded Script Page that Controls the Splash Panel if ((!refer_type && !navtype && (viewportWidth > 360)) || !cookie_set) { [the code that sets the splash panel] } QUESTION: Can you see anything in the above logic or design that could be showing the splash panel when it is not desired? Roddy
  14. OK. I will try both ways. If I cannot simply drop the parameter, then I will try as davej has suggested and put nothing as the value. Roddy
  15. BACKGROUND: I would like to use the following HTTP Request query string, but substitute the empty quotes with something like null or undefined. What are acceptable non-values in this instance? "https://www.nudge.online/_utilities/php/matomo/index.php?module=API&action=index&method=Events.getCategory&url=www.grammarcaptive.com&idSite=1&period=year&date=today&segment=''&expanded=''&secondaryDimension=''&format=json&token_auth=363130ebb19736863e42030f91269e40"; Roddy
  16. Never mind. I got it. .show() => .slideToggle(0 It was so easy! No wonder, I could not figure it out. Roddy
  17. BACKGROUND: The following piece of code is a little tricky, because it requires insight into more than what is shown. So, please allow me to show and tell, rather than only tell, and invite you to click on the menu option Sponsor Overview under the subheading Visitor Profile in the navigation bar of the Grammar Captive mainpage. Once arrived click on either of the two items entitled Visits per Number of Pages or Visits per Time Spent and then click again on the same item. What shows and what disappears are different. Now, I well understand why this occurs, but everything that I have tried to correct for it has failed. Indeed, I would like the toggle to effectuate a complete disappearance of both explanation and data, rather than just the explanation. The CODE $(".so_clarify, #visits_per_number_pages, #visits_per_duration").css('margin', '1em 0').hide(); $(".so_param").mouseenter(function() { $(this).css({"cursor":"pointer","font-weight": "800","color":"#ffffff"}); }); $(".so_param").click(function(event) { var index = $(".so_param").index(this); $(".so_clarify").eq(index).slideToggle(function() { if (index == 8) { $("#visits_per_number_pages").show(); } else if (index == 9) { $("#visits_per_duration").show(); } }); }); $(".so_param").mouseout(function() { $(this).css({"cursor":"none","font-weight": "normal","color":"#fadb9d"}); }); Roddy
  18. So, in addition to including the file in which the class is defined and calling a public static function within the file with its name and namespace as I have done what is a likely reason for not finding the class? Please allow me to try a different line of questioning. Consider the following list of uses and the corresponding namespace taken from the ExceptionHandler.php file. Must each file containing the respective listed class be included by PHP in order for the class to become available, or will PHP find the listed classes on its own? namespace Piwik; use Exception; use Piwik\API\Request; use Piwik\API\ResponseBuilder; use Piwik\Container\ContainerDoesNotExistException; use Piwik\Plugins\CoreAdminHome\CustomLogo; And, to take the matter one-step further must I include the additional uses included in each of the above, respective, class files in order to achieve my goal? I ask this for there is hardly a file that does not contain its own unique set of uses. Roddy
  19. NATURE: This is part of a steadfast effort to hack through the thicket of PHP classes and namespaces of which the Matomo application consists. It is not an endeavor for the weak or timid, as the thicket is formidable and the documentation obscure. BACKGROUND: In order to submit a proper report request to the Matomo application the values of certain variables must be known. Although there are generators within the application that have been created to achieve this task, they are not easily accessible, as the thicket is, well, thick. Please find below both the file and code that produces the error message provided. The FILE: <?php /** * Piwik - free/libre analytics platform * * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * * @package Piwik */ use Piwik\ErrorHandler; use Piwik\ExceptionHandler; use Piwik\FrontController; if (!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER) { ErrorHandler::registerErrorHandler(); ExceptionHandler::setUp(); } FrontController::setUpSafeMode(); if (!defined('PIWIK_ENABLE_DISPATCH')) { define('PIWIK_ENABLE_DISPATCH', true); } if (PIWIK_ENABLE_DISPATCH) { $environment = new \Piwik\Application\Environment(null); $environment->init(); $controller = FrontController::getInstance(); try { $controller->init(); $response = $controller->dispatch(); if (!is_null($response)) { echo $response; } } catch (Exception $ex) { ExceptionHandler::dieWithHtmlErrorPage($ex); } } The CODE: require_once ('../../../../nudge.online/_utilities/php/matomo/core/dispatch.php'); The ERROR MESSAGE: LINE 16 ErrorHandler::registerErrorHandler(); Now, including the file ErrorHandler.php does not help. Neither does a call to the static function registerErrorHandler() appear to make a difference. Piwik\ErrorHandler::registerErrorHandler(); For the response is always the same Any ideas? Roddy
  20. No, I am saying that adding the script <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> via the str_replace() removes the namespace problem, but it generates a new problem that I do not understand. For the moment, I have decided to return to the old problem of getting Matomo to work without HTTP requests. There must be a way to simply enter the information contained in the query statement without having to generate an HTTP request. In exploration of this route I have stumbled on something that I have never seen before: a class without a constructor function. The whole of it is given below. It is brief. <?php /** * Piwik - free/libre analytics platform * * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ namespace Piwik\Http; use Piwik\Url; /** * Router */ class Router { /** * Filters some malformed URL by suggesting to redirect them. * * E.g. /index.php/.html?... can be interpreted as HTML by old browsers * even though the Content-Type says JSON. * @link https://github.com/piwik/piwik/issues/6156 * * @param string $url The URL to filter. * * @return string|null If not null, then the application should redirect to that URL. */ public function filterUrl($url) { $path = parse_url($url, PHP_URL_PATH); if (strpos($path, 'index.php/') !== false) { return preg_replace('#index\.php/([^\?]*)#', 'index.php', $url, 1); } return null; } } How do you explain such a thing? Roddy
  21. Using str_replace( ) was a great idea, and I am a little embarrassed that I did not think of it myself. Although it achieves the task, it does not solve the problem, for as soon as the ready() function is successfully invoked an error is triggered ReferenceError: broadcast is not defined <anonymous> n.Callbacks/j() jquery.min.js:2 n.Callbacks/k.fireWith() jquery.min.js:2 K() widget_map.php:61:13 POST XHR https://www.nudge.online/_utilities/php/matomo/index.php [HTTP/1.1 200 OK 1201ms] and then the POST call is repeated over and over as if in an unending loop. The line of code that triggers the error is, of course, var segment = broadcast.getValueFromHash('segment'); Roddy
  22. Do you agree with the following statement from StackOverflow? Roddy
  23. But where, and how? If I knew how to do this, I would have done it long ago. Already, before I wrote the above entry, i had tried placing a <script> tag with a src attribute pointing to the jQuery library outside of the <?php ... ?> in the same file in which the cURL resides. It was simply ignored -- perhaps due to the absence of a document or head tag. I know to little about the general use of headers and browsers to know why it failed. Roddy (spelled correctly)
  24. If the absence of the jQuery library is, indeed, the source of the problem, then how would I add the <script> element that loads the library to the file imported by the cURL call? It appears that cURL has several options to achieve such a task. Roccy
×
×
  • Create New...