Jump to content

iwato

Members
  • Posts

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. BACKGROUND: I have a plain text file with an .html extension. In the file is a <p> element into which I would like to enter the current date. The file is called from its hostpage via a jQuery $.get() statement that is followed with an AJAX call to a PHP processing file that returns JSON that can be processed in the AJAX success function as an object. QUESTION: If I place the PHP necessary to create the date in the text file with the .html extension, will it appear in the hostpage when called by the $.get() method? NOTE: My server is programmed to accept PHP in files with a .html extension. Mind you, the text file has neither <head>, nor <body> element, let alone a <DOC> header. Roddy If I enter the data with PHP before the AJAX
  2. Hi, Kayut! The w3school Team appears to be on vacation. Have you tried jQuery? It is reformatted Javascript. So you can easily intermix the two. Below is all you need. <script> $(".demo").css("border","1px solid red:); </script> Roddy
  3. Dsonesuk: Even something else? Roddy
  4. BACKGROUND: Recently I learned how to embed directly a Matomo widget into my website. Although there are several ways to make this happen, I am only able to achieve two of them at this time: one, gives all autonomous users access to all Matomo's reporting widgets and a large number of reporting methods; the other, exposes the superuser's authorization token that would leave a disastrous breach in database security. DILEMMA: Although I am able to retrieve the widget via CURL in an invisible PHP file, and consequently embed the widget's contents via the src attribute of an iframe, I am not able to do so with the same rich formatting that can be achieved when the same HTTP request is placed directly into the src attribute of the iframe. Either cURL is stripping away valuable information or the Browser is unable to process the information provided in the format provided. QUESTION: What must I do in order to get cURL to behave in a manner that produces information compatible with an ordinary web-browser? Roddy
  5. I understand the nuance, but I am now confused about the prototype property. Is it a single property with only one value, a single property with many values -- say, an array --, or something else. Roddy
  6. JSG: You are correct. Removing the line breaks does perform a proper download and insert. What I usually do -- unformat my HTTP requests before sending -- I did not do in this case. I was falsely led to believe by own implementation that it would not make a difference. Indeed, the same that works in an HTML document with the correct headers, does not work in a PHP file with no headers. Which brings me to my next question. How must I set the PHP header function to insure that the downloaded content is properly formatted into the src attribute of the iframe? Among other things the CSS styling and images are missing. The link functionality is also lost. In the meantime I was able to discover that the content-type of the returned data is text/html; charset=utf-8. I was able to discover this via the using the CURLINFO_CONTENT_TYPE option suggested by the furtive fox. Please understand that what I am requesting is a Matomo widget designed to display a certain body of dynamic knowledge that includes various kinds of images ranging from icon highlighting to functional maps. One further thought, once the proper MIME-TYPE is discovered where should it be entered? In the requesting CURL, at the top of the PHP document that is making the request, or somewhere else. The browser is obviously doing something that CURL is not. Roddy
  7. Matomo allows three channels of external access to the Matomo program: piwik.php (644), piwik.js (777), and the bot request text file whose name I do not remember. Each of these channels is accessed via an HTTP request (secure or unsecure, with the option to enforce security). The piwik.js channel is for webpage data collection. The piwik.php channel is used for data reporting. The superuser who logs in with his name and password has the authorization to permit anonymous users unlimited access to Matomo's reporting API (read piwik.php). He can also specify named users. Whether an anonymous or named user the privileges are the same -- unlimited use of the reporting API. I do not wish to offer unlimited use, rather, restricted use. Unfortunately, within the current configuration I have no way of granting restricted autonomous use. It is nothing or everything for everyone or the same for a select number of users. All of the critical user information is located in a folder called config. This folder is a sibling with all other Matomo files and folders located in the Matomo package. Inside the config folder is a .htaccess file. Eliminating this folder provides me with the access needed to manipulate the files and folders of Matomo without having to make HTTP requests. In effect, the Matomo package and the Grammar Captive website are located in different branches (add-on domains) of the same root directory. It seems obvious that the just mentioned .htaccess file is critical to integrity of the Matomo package. It is the guard dog to the entire PHP package. I need to set the biscuit that will silence the dog as I pass in and out, else I will have to perform all of my commands through HTTP requests, and even is already causing trouble as can be seen through another W3Schools posting. Roddy
  8. Have you tried .attr(data)? Roddy
  9. So, I replaced the curl_exec() statement with the following if(curl_exec($curl_request) === false) { echo 'Curl error: ' . curl_error($curl_request); } else { echo 'Operation completed without any errors'; } curl_getinfo($curl_request, CURLINFO_REDIRECT_URL); and received the following at the bottom of the log-in page that appears in the iframe. Operation completed without any errors CURL is happy, but I am sad and must soon go to bed. Roddy
  10. Yes. Good call. Unfortunately, the problem is not resolved. For, where before there was nothing, it is now asking me to log in, as if I were going through the frontdoor. Keep in mind, the only difference between what I am trying to do above and what is already working on the same page is what I have already explained. In the first instance the loading of the iFrame content is indirect; in the second instance it is direct. So, I added the following two lines of code to my PHP file: curl_setopt($curl_request, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($curl_request, CURLOPT_USERPWD, "[...]:[...]"); with the required name and password. Unfortunately, nothing changed. Any idea as to why cURL is being rejected? Roddy
  11. Nothing appears in the frame. What follows is the code. My last experiment among several. The iFrame <iframe id='dashboard_map' src='./widget_map.php'></iframe> The PHP (widget_map.php) <?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); $url = 'https://www.nudge.online/_utilities/php/matomo/index.php ?module=Widgetize &action=html &widget=1 &moduleToWidgetize=Live &actionToWidgetize=widget &idSite=1 &period=day &date=yesterday &disableLink=1 &widget=1 &token_auth=...'; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 0); curl_exec($curl_request); curl_close($curl_request); } ?> Now, the same URL provided above works if embedded directly into the iFrame. Roddy
  12. BACKGROUND: I would like to embed a Matomo widget into a page, but I dare not embed it directly. For, to do so would require that I expose the authorization token that enables knowledgeable visitors of Matomo -- and coding in general -- the ability to view everything about my website that I am able to view. As I, myself, do not yet know what to do with everything that Matomo makes available (it appears endless), I certainly do not want to put it all into the hands of others willy-nilly. It is simply bad business. OBJECTIVE: Read the data into a PHP file, and load the result into the src attribute of an iframe. Below is sample code taken directly from the Matomo website. (The absence of the authorization token assumes that the superuser has given access to all users the right to view whatever they like. I do not wish to grant this privilege). SIMPLE URL https://www.nudge.online/_utilities/php/matomo/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=Live&actionToWidgetize=getSimpleLastVisitCount&idSite=1&period=day&date=yesterday&disableLink=1&widget=1 EMBEDDING CODE <div id="widgetIframe"><iframe width="100%" height="350" src="https://www.nudge.online/_utilities/php/matomo/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=Live&actionToWidgetize=getSimpleLastVisitCount&idSite=1&period=day&date=yesterday&disableLink=1&widget=1" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div> Obviously, there is no difference in the URLs. QUESTION: If an image can be created by a PHP file and then read into the src attribute of an image tag, surely it must then also be possible to read the HTML content of a PHP file into the src attribute of an iFrame. What is the necessary header argument required? I have tried both " header('Content-Type: text/html'); and header('Content-Type: text/plain'); Neither works! Or, am I just guessing. And, what I am trying to do simply does not work. Roddy
  13. I have already spent several days. I know enough to know that something is possible, but in this case do not know enough to do it myself. Security has rarely been an issue for me, because up until now my livelihood has not depended on it. I humbly disagree with you about the GDPR and the NSA. I know of know government that does not wear two faces: one of benevolence, and the other of power, control, manipulation, and self-interest. The GDPR is a show of unneeded protective benevolence to cover for what is truly going on behind the scenes. You are naïve to think otherwise. If the EU cared, then it would educate the European public about the reality of data collection and not interfere with private enterprise. There are enough laws on the books already to handle the problem of identity theft and the abuse of private information. Roddy
  14. Does it not depend on the problem that you are trying to solve? The second example simply creates an object with two properties and assigns a value to each. The third example creates a function that fixes the value of one of the properties, allows you to assign a value to the other property, and provides a means to recover the information about both properties via a function that you can assign to the newly created instance. If I have properly understand your intention, rather than your words, a better comparison would be var theDude = { name: "David", age: 20, }; and function Person (name, age) { this.name = name; this.age = age; } var theDude = new Person("David", 20); In which case you are left with the same question. What is the intended purpose of creating the object? In both cases you are creating an object that you are assigning to a variable called theDude. Now, why would you prefer one over the other do you think? Roddy
  15. I would like to share with you a message that I posted on the Matomo forum for which I am not expecting a satisfactory reply. I suspect that Matomo will be unwilling to entertain the idea for fear of opening a Pandora's box of insecurity for casual users and thereby endangering its reputation as a secure web utility. Matomo's fear need not be my own, however, with the proper guidance. BACKGROUND: After several weeks of enormous frustration I was finally able to access the Matomo web application directly with PHP. I was able to achieve this somewhat (for me) monumental task by renaming the .htaccess file (see below) in the /matomo/config folder and thus canceling its prohibitive effect. Obviously, this file was placed in the /matomo/config folder as a matter of security -- security, mind you, that I do not wish to compromise. This said, an unending series of HTTP requests uses up an enormous number of resources, and I wish to share the data that I collect about my users with my users via my own custom-built PHP files for which I require direct communication with the Matomo application. (I have no desire to play the governmental game of protect-and-deceive -- read GDPR or NSA). So, I explored the internet and found alternative contents <https://www.slicewise.net/php/piwik-absichern/> to the current .htaccess file in use by Matomo as of 3.5.1. REQUEST: Would anyone like to comment on the merging of these two files (see below) into a workable arrangement that would give me the superuser direct access to the Matomo web-application via PHP, but deny access to everyone else except through those channels already set in place by Matomo for anonymous users and opt-in/out visitors. PROPOSED FILE <Files "*"> AuthUserFile /path/to/piwik.htpasswd AuthName Piwik-Password AuthType Basic <RequireAny> Require valid-user Require ip 127.0.0.1 <your-server-ip> #needed for some scripts </RequireAny> </Files> <Files ~ "^piwik\.(js|php)|robots\.txt|idxsec\.php|favicon\.ico$"> Require all granted </Files> CURRENT FILE <Files "*"> <IfModule mod_version.c> <IfVersion < 2.4> Order Deny,Allow Deny from All </IfVersion> <IfVersion >= 2.4> Require all denied </IfVersion> </IfModule> <IfModule !mod_version.c> <IfModule !mod_authz_core.c> Order Deny,Allow Deny from All </IfModule> <IfModule mod_authz_core.c> Require all denied </IfModule> </IfModule> </Files> My goal is to give my visitors an important glimpse into the reality of data collection and analysis. I now know that I am able to do this my eliminating the .htaccess file. Elimination of the file is, however, not my goal. Roddy
  16. Make sure that $result is not empty. Enter $result = $stmt->execute($uniqueValueArray_id); below $result = $stmt->execute($uniqueValueArray_id); and make sure that $result is not empty. Also make sure that you are using the proper fetch-style. I do not use PDO, so I cannot help you any further. Roddy
  17. It took some time to find it, but I was finally able. Unfortunately, I was unable to find anything in Chrome, and I have long since given up on Safari, as it is next to useless in my current operating environment. The following is the procedure used to display the structure and contents of a result object that is generated in a PHP file called with an AJAX request. Open the Firefox Console and find the Network tab. While in the Network tab find the javascript (.js) file responsible for calling the PHP file that generates the JSON object. Highlight the file by clicking on it. While the file is still highlighted click on the XHR tab. This will cause the relevant .php file(s) to appear below the highlighted .js file. Click on the PHP file of interest and find the Response tab in the appropriate corresponding box. It is in the viewport of this box that the object appears. Click on the various objects, arrays, and other components of the object to learn how it is structured and to display the values. Have a great weekend! Roddy
  18. So, in conclusion, .pad(size) is a user-created method of a primitive Number object that is called via the Number.prototype property and executed by either the parentheses operator or variable assignment. Do I have everyone's agreement. Roddy
  19. Oh well, infinity wins out. For, it is only bounded by the imagination, and it seems to be without end. At least, until I die, and someone else's carries on. Roddy
  20. PRAISE and ADORATION: I would like to thank you for a very wonderful post. It was very readable and hence very helpful. So much so that I have created a private webpage to capture its insight. Also, my URLs no longer extent beyond the <fieldset: element in which they are contained. Hooray! Hooray! iRONY: Although I understand fully what is meant by the following, it is only because I have worked long enough with CSS to get the gist. Taken at its face value this statement is completely contradictory: This is CSS in a "nut"-shell. Roddy
  21. Dsonesuk. thank you, but I am only unclear about that part of the implementation that encloses the number 2 in parentheses. Why is the number two enclosed in parentheses? Roddy
  22. Great! But ... I still do not understand it. What pray-tell is the meaning of the numbers enclosed in parentheses. Do the parentheses convert the number number into an object? Roddy
  23. GENERAL: One of my colleagues claims that no one likes CSS. But surely, someone does, else it would not exist. Unfortunately, I am not one of those who is very fond of it. Probably because I do not understand it. Dsonesuk once told me that id takes precedence over class. The furtive fox told me to insert my stylesheet dynamically, so that I would be sure that the needed CSS would be present when my dynamically HTML was in need of it. I have accommodated my CSS specification in both of these ways, but still it does not work. Rather, when I visit the Inspector menu of my web-console, it looks like a graffiti-board that someone was too lazy too clean and on which he simply crossed out everything that he did not like. SPECIFIC: I am trying to get my referral URL to break when it gets to the end of the div block in which it is contained. In order to achieve this I entered the following piece of code in my stylesheet. The url does not wrap. Although the inspector of my web console indicates the presence of my specification, it also shows that the rule has been cancelled. Truly I do not get it. #yp_container #current_referral_url { overflow-wrap: normal; } SOURCE: Please open to the mainpage of the Grammar Captive website and click on the phrase Your Data and You under the heading Visitor Profile in the navigation bar. Look for the term Referral URL and note, if you are able, that the URL exceeds the size of the fieldset and div in which the value of the URL is contained . QUESTION: What more must I do to achieve my goal?
  24. PROBLEM: The following script is purported to add a select number of zeros to the left of a numerical value. Although it appears logically correct, I do not know how to call the function thus created. The SCRIPT Number.prototype.pad = function(size) { var s = String(this); while (s.length < (size || 2)) {s = "0" + s;} return s; } REQUEST: Could someone please give an example of how I could convert the number 2 to appear as 002 using the above script. Roddy
  25. OK. I have fixed the problem. I am now able to get prettyDate to appear. Clearly I misunderstood the structure of the object read by the $.ajax( ) success function. My having misinterpreted the structure of this object was no casual error, however. For, the object consists of nearly 2000 lines of comma separated property-value pairs, nested array-like structures, and the like. As a result, I am of the firm conviction that similar errors will occur in the future until I learn how to traverse and display the content of the object that I am dealing with. Visual inspection, something that I can now do, is not enough, as I have no means of collapsing the various sub-elements of the object. This said, surely there is a formal methodology for parsing the structure of a complex, many layered JSON object with Javascript. Can this be achieved through a single, highly flexible, recursive function? Or, must it be achieved one layer at a time through painstaking trial and error? Still this latter would be better than what I am doing now. Could someone, please, point me to a tutorial about how to parse and display such an object. Roddy
×
×
  • Create New...