Jump to content

kicken

Gurus
  • Posts

    4714
  • Joined

  • Last visited

  • Days Won

    182

Everything posted by kicken

  1. What you downloaded is the source code of the software. You need to compile it to get an actual program you can use. You can do that relatively easily on Linux since that's the environment it was designed for. Whether it can be done and how difficult it would be to do on Windows is unknown. Something like MinGW might help. A .md file is just a text file. Any text editor will open and display it just fine. It might not open with a simple double-click as the .md extension probably is not registered, but you can always open the editor and use it's file->open command (or just rename the file to .txt and double-click).
  2. An object-oriented approach has a lot of benefits over a functional approach, particularly when paired with a good IDE. Autoload support If you structure your classes according to the PSR-4 standard, you can let an autoloader script manage including your classes when needed. This means you no longer have to manual deal with making sure you have included the correct files on your pages, or just include everything to be safe. You can just use your classes as needed and let your autoloader script automatically include the class file when necessary. Autoloading of functions is currently not possible, though that might change eventually. Data management Something every program needs to do is manage and work on data. With a functional approach, that often means you use a lot of associative arrays to hold your data and pass those array's between functions. While this works, over time it becomes hard to manage as you will loose track of what keys exist in what arrays and different code paths may end up diverging in how they manage those arrays. Even using just simple objects can help with this by providing predefined properties for your data structures. When paired with a good IDE, you will be able to able to easily see what properties are available on an object, get auto-completion of property names as you code, and easily refactor the data structure if necessary (ie, rename a property). Automated Testing OOP lends itself well to automated testing thanks to features like interfaces and inheritance. With functions, you end up with hard-coded references to other functions through out your code. The implementations of those functions cannot be easily changed for testing. By passing around objects and calling methods instead, you can easily replace your real object with a fake / mock object for testing purposes. To take full advantage of this, you need to not just use OOP, but also techniques like dependency injection so you don't just replace a hard-coded function with a hard-coded class reference. Reuse While both functions and classes allow one to re-use code, I generally find that making reusable code is easier done using an OOP approach. Often in order to be reusable, code needs to be flexible. To manage that with functions you either end up making a lot of different functions, or your functions need to have a lot of parameters (or a single large array parameter) to control the functions behavior. This leads to a messy code base and can make future edits hard to make without inadvertently affecting some use case. With an OOP approach, you can control behavior though either properties that can be set individually as needed, or by breaking things down into various objects that can handle different use cases. This lets the code be cleaner by removing various conditional branches and helps isolate future changes to specific areas without affecting other areas. You need to know OOP anyway. The vast majority of libraries out there are using OOP, so if you want to take advantage of other peoples work to save yourself time (ie, the various frameworks or even just individual libraries) you need at least a basic understanding of how OOP works. You don't need deep knowlege of everything OOP and all the design philosophies t hat go with it just to use a few libraries, but you do need basic syntax and structure knowledge to understand the library code and know how to interface with it. The more you know though, the easier it is to integrate with libraries and customize them to suit your needs.
  3. As has been said already, Webalizer is pretty much a dead project. The FTP server is apparently no longer running so you cannot download from it. If you really want a copy you can get it from the internet archive using the wayback machine. https://web.archive.org/web/20150905053743/http://www.webalizer.org/download.html Unless there is some specific reason you must use Webalizer though, you should probably look into a modern alternative.
  4. From the PHP perspective your dummy column is the same as any other column. If you want to echo it, you just echo $row['dummyColumnName']. You probably don't want to echo it though, you want to use it to determine which table the row came from using a simple if. if ($row['dummyColumnName'] === 'A'){ //$row is from the first table } else { //$row is from the second table. } I suspect you might not understand what a union is for. Generally speaking, you shouldn't need to use a union. If you do, it might be a sign that you're database design needs to be re-worked. There are some reasons for it's use, but they are not all that common. I don't know your data or what you're trying to do but I'd guess that a union select probably isn't the right solution.
  5. You might be misunderstanding what ::before does, or maybe my usage of parent. The selector ::before is a pseudo-element that is placed before the content of the selected element, not before the actual element. For example, the html: <div class="hello">World</div> With the CSS .hello::before { content: "Hello"; } Would be rendered as if you had written this HTML <div><span>Hello</span>World</div> The pseudo-element is a child of the selected element. As such, any padding on the selected (parent) element affects where the pseudo-element is rendered.
  6. For the section of the page you're showing, the problem is that your background issue is absolutely positioned over top of the ::before element. You can work around this by adding to your style position: relative; z-index: 10; That will make the gradient show, but it won't be positioned correctly due to the padding on the parent element. You'll need to adjust that styling to get what you want, and probably other page styles.
  7. You probably need to update your php and/or openssl and/or libssh versions. The error is likely because your client does not support any crypto algorithms that the server does so the encrypted channel cannot be established.
  8. By row are you talking about a <tr> table row? What's the HTML that goes along with that CSS?
  9. From the manual: So when you're dividing your timestamp variable, you get a floating point number due to the values not dividing evenly. Attempting to use % on that result causes PHP to convert it to an integer instead, loosing whatever fractional value existed in the process. In the past, this happened silently. Now there's the notice about it to highlight the potential bug. Convert your floating point value to an integer value yourself explicitly to remove the error. You can do this in that code by just changing the floor function to only operate on the division instead of the whole expression. $hours += floor($timestamp / 3600) % 24; $min = floor($timestamp / 60) % 60;
  10. There is a concept in design/engineering called Hysteresis. In a nut shell, you don't define hard cut-off points and instead define a range, or introduce a delay of some sort. So instead of having your code hide the menus when the container is <50 px from the top and show them when 50px or more from the top, you instead set it up such as: If container is <50 px from the top, hide the menus If container is >150px from the top, show the menus. If the container is between 50px and 150px from the top, just maintain whatever the current state is. The range can be fixed like the example, or dynamic by calculating the menu heights. You just need the range to be large enough that toggling the visibility of the menus doesn't cross both boundaries.
  11. Unless you have code somewhere above that conditional that is doing $pageimg = $row['pageimg']; then the variable $pageimg is not the same as $row['pageimg']. That's why I asked to see how it's being defined. It seems to me like maybe you are expecting that $pageimg just magically exists because it's the name of a column in your DB table, but that's not how things work. If you don't assign a variable a value at some point, then it doesn't exist. And if it doesn't exist, then using empty() on it will always return true, which is the problem you seemed to be having.
  12. Where do you define the variable $pageimg then? Why are you using two variables instead of just the row result?
  13. The JS from my post only sets up the event handling for the click event. It still needs the copyToClipboard function from your original post to work.
  14. You don't have the copyToClipboard function in your code.
  15. It's generally better to just avoid ID's entirely. Use classes or your HTML structure to find the elements you need instead. Your HTML is hard to read being all in a single line like that, and using nl2br on a single line is fairly pointless. The code would be a lot nicer if you spaced it out and made it readable. You might then notice that you have an error in your HTML in that your copy button has two name attributes. Once that is all fixed up, you'd have something like this: echo " <div> <div class='copy-content'>".nl2br($row['info'])."</div> <br> <a href='updatecopypaste.php?id={$row['id']}'><img src='/ppreq/editbtn.jpg'></a> &nbsp &nbsp <a class='leftf' href='deletecopypaste.php?id={$row['id']}'><img src='/ppreq/deletebtn.jpg'></a> &nbsp &nbsp <button name='copy-button' class='unstyled-button' style='cursor:pointer'><img src='/ppreq/copybtn.jpg' border='0'></button> </div> <br><br> "; Your copy button and copy content are now wrapped in a common parent element, which will make it easier to locate one relative to the other. There are no more IDs so no more conflicts that need to be handled. The content is identified via a class and your button via a name, both of which can be duplicated. Now you need to create a single piece of JavaScript that can respond when any of the copy buttons are clicked. That JavaScript code would use the button that was clicked as an initial point of references in the document, and locate the content to be copied by looking for the element with the class copy-content contained within the same parent element as the button. window.addEventListener('DOMContentLoaded',()=>{ //Find all the copy buttons document.querySelectorAll('button[name="copy-button"]').forEach((button)=>{ //Add a click handler to each of the buttons button.addEventListener('click', (e)=>{ //Locate the copy-content element const copyContent = button.parentElement.querySelector('.copy-content'); //Do the copy copyToClipboard(copyContent); }); }); }); Example.
  16. The redirections are part of the setup for running a command. > and < tie the STDOUT and STDIN streams to a file. This processing is handled by the shell, not the program being executed, so they are not considered part of the programs argument list. Since this is pre-execution setup work as well, the redirection happens before the program is executed, thus happen even if the program execution fails. So, given the command line: zcho It is cold today! > winter.txt The shell would Parse the line into it's components Argument list: ['zcho', 'It', 'is', 'cold', 'today!'] Redirections: STDOUT -> winter.txt Setup STDIN, STDOUT, and STDERR STDIN: tied to the shell's current STDIN stream STDOUT: tied to a new stream created by opening winter.txt for writing (with truncation) STDERR: tied to the shell's current STDERR stream. Extract the first argument and use it as the program/command name (zcho) Attempt to execute the program/command with the arguments given You can confirm the redirection happens first by running your invalid command with STDERR redirection: kicken@web1:~$ zcho It is cold today! 2> error.txt kicken@web1:~$ cat error.txt -bash: zcho: command not found The error message from the zcho command is redirected to the error.txt file rather than displayed in the terminal.
  17. Why? It can be done in a round about and terrible way, if your version of MySQL is new enough. select * from ( select *, row_number() over (order by salary desc) as rowNumber, count(*) over () as totalRows from employee ) r where r.rowNumber = r.totalRows-3 It'd be far more efficient and easier to read just doing and ASC sort and taking the 4th row. You can't do a simple limit expression with a single query because the numbers in the limit cannot be column references. You have to instead find a creative way to count the rows then select the one you need based on that count.
  18. As far as I know, the standard allows for columns that are directly dependent on the group by columns to be used as well. For example, since orders.OrderId is a primary key, any other column in the orders table could be selected as well since there will only be one value for any given order id. The same would be true for customers.CustomerId and employees.EmployeeId. The way you are doing the joins would ensure there's only a single values from those tables for any given order ID, so in theory you could select any columns from those tables as well. In practice, whether a DB supports this type of analysis of the situation or not can vary. MySQL must support it to some extent. Microsoft's SQL server doesn't support it at all so you have to follow the rule of thumb describe above. I'm not sure about other DB systems. Since support varies, the safest thing to do is just follow the above rule of thumb and limit the select to your group by columns and aggregate functions.
  19. That when you use GROUP BY, the only columns that can be in your SELECT clause are Also listed in your group by clause or Used with an aggregate function so that multiple values get condensed down the a single value.
  20. querySelectorAll returns a NodeList, which does not have an addEventListener method. Assigning an event handler to a collection of elements is a jQuery thing. In plain JavaScript, you have to loop over the elements in the collection and assign the event handler to each one individually, or attach it to a common parent element. document.querySelectorAll("p").forEach((e) => { e.addEventListener('click', fn); });
  21. shell_exec is an example of where such functionality is used. The function is used to run a shell command, which is done by executing the shell program with -c. So in your code something like this: shell_exec('someCmd && someOtherCmd >/dev/null'); Is translated into /bin/sh -c 'someCmd && someOtherCmd >/dev/null' and executed by the OS. Essentially, the use case is for whenever you have a command stored in a string that you want to run. It's not something you'd typically use directly in a terminal, but rather in a script or program.
  22. You wouldn't do the comparisons in JavaScript, you'd do it in PHP when building your UPDATE query. Select the current data from the DB, compare it with what you received, then UPDATE whatever has changed. I wondered the same thing a while back, as this is something that Doctrine ORM does. I use MS SQL Server and from what brief searching I found, it does make a difference there. If I understand correctly, SQL Server like MySQL won't re-write the same data to disk, but it does record an entry in the transaction log. As such, unnecessary writes can cause increased overhead when it comes to transaction log management / replication. That said, I've never bothered doing this and instead just updating all the fields. I believe this level of optimization isn't really necessary until you get to pretty large applications. Adding the change detection complicates your PHP code and requires more processing overhead there so it's kind of a trade-off. Adding overhead to your PHP code and lowering the load on the DB is preferred though, as it's easier to scale your application code processing than it is to scale your database server.
  23. I would probably look into using WebSockets for this if possible. Have the clients connect to a WebSocket server and obtain the initial time to display. Each client handle updating the display itself using some local timing, potentially with a periodic sync. Whenever the admin pauses/starts the timer, broadcast that event + the current time to each client so they can pause/start their display and sync it.
  24. Yes, for example, in Thunderbird which is what I use, there is this setting: Unless that is checked, anything that requires accessing a remote server to display will not be loaded. The learn more link goes here if you're interested. Since I leave that setting off, most of the marketing emails I get end up like this: A little bit of text, lots of image placeholders / alt text. Some companies manage this better than others. Attaching images or using data: url's will allow them to show, but of course that doesn't help you with your desire to track things.
  25. Did you enable remote content in your email client? Most block it by default as far as I know.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.