-
Posts
5,959 -
Joined
-
Last visited
-
Days Won
146
Everything posted by gizmola
-
As for it disappearing, there's clearly some bug in your code. I don't know exactly what your code looks like, but you need to debug the html using devtools, to see what has gone wrong. You should revert the changes suggested by Barand, back to your original code if you plan to use the ideas I have proposed. They are based on your original code.
-
Also, you have not given your table an id. In my example, it would need to be <table id="myTable">
-
No you missed the fact that the column needs to be incremented for each cell. MyFunction(0, MyFunction(1, MyFunction(2, ... MyFunction(6,
-
This is why I linked you to the github project. Did you take a look at it? Clone and run it locally? Try and understand what it does and how it is designed? It's essentially a sort of PHP SPA. If you look at all the functions I had to add for the simple routing and handling of the form, you get an idea of what a routing class, or the HTTP classes that lots of projects (Laravel included) borrow from the Symfony components. In summary, frameworks are a collection of different component classes, usually with things like configuration figured out. My demo project includes use of a "dotenv" processing class, which is best practice for web app configuration of things like database credentials which should not be hard coded and stored in your source code repository. You don't have to use use an entire framework, but instead can use components you find helpful. Also, again, DBAL wraps PDO. By using DBAL, you will be using PDO, only in a simplified form. It has some very nice features, one I illustrated and documented. When you use symfony or laravel, you won't be using PDO directly -- you use their ORM that then uses PDO for you. My project would have been even smaller and simpler if I'd used the Symfony Http foundation component. My point is, that modern PHP development should always start with the user of composer, and a skeleton directory setup with a /public directory where directly executable scripts will go. All classes should go into either your own component, or in an app space. You make at most a few modifications to the composer.json, and as you develop, rely on composer to generate the autoloader you need, which you include in any of the script that directly execute within /public. An alternative to that is to create a bootstrap include that does the same thing, and include that in all your directly executable scripts.
-
Please read my updated post. It has nothing to do with the database. It is the way you created the html table of dates and times. The dates in the first table row are in no way connected to the times, and I don't think Barand saw that. If you had one unified computation that would be a better solution, but I basically provided you a hacky way of getting to where you want to be, albeit in a less elegant way. Using data-* elements are a better practice for connecting static data to html elements, which would be simpler, but you would also have to rewrite things that already work for you, and I would suggest you just get it working with what you have.
-
You have painted yourself into a bit of a corner because the Dates computed in the first row are disconnected from the time period slots. When you click on a cell in the table, you not only need to determine what the time period is, but also what day that time period is relevant to. This is essentially what Barand is trying to help with. While I agree that would be a great solution, I don't think he realized that the timeslots don't correspond with the dates, so this is not going to work, until a connection is made between the two. One way to get around this would be to use javascript to get the date value from the first row, and the corresponding column inside MyFunction. To facilitate this you should give the table an id, so you can select it easily. Then you can do something like: function MyFunction(col, time) { const tbl = document.getElementById("myTable"); let dateValue = tbl.rows[0].cells[col].innerHTML; // Set the Form Date element value using dateValue // Set the Form Time element value using time ) Change the table output to something like this: <td><a href="#" onclick="MyFunction(0, '<?php echo $ts; ?>');return false;"><?php echo $ts; ?></a></td> <td><a href="#" onclick="MyFunction(1, '<?php echo $ts; ?>');return false;"><?php echo $ts; ?></a></td> etc.
-
Warning: file_exists(): open_basedir restriction in effect. File
gizmola replied to kako0000000's topic in PHP Coding Help
These messages are all related to the open_basedir settings of your php installation. You need to locate the php.ini file for your system. Either a script that only has phpinfo(); in it, or use of cli php run with php -i will let you see where the configuration file(s) are located. On most systems, the base php.ini will load files in a subdirectory like /etc/php.d. You can ignore those files if they do exist, as the open_basedir configuration will be in the main php.ini script. The first place to look would be /etc/php.ini, but you need to be sure that you are editing the actual php.ini being loaded when you run your script. In some cases, there are different php.ini files so that php used with a web server can be configured differently from the cli version you use to run command line scripts with. Once you are sure you are changing the correct php.ini, edit it with a text editor and look for the line open_basedir = You can either add the directories in question to the list you find, or disable it entirely by adding a ; before the line like this: ;open_basedir = If this script is being run through a webserver, then you would want to restart the web server, or possibly php-fpm, if that is your web server configuration. If this is a cli script, running it again after you added the directories or disabled open_basedir should solve the issue. -
It would be helpful if you provided the version of libssh on the client server running php, as well as the php version. Likely this issue is that you have libssh2, and the message is telling you that the key exchange doesn't work. This is because libssh2 upon which the php routines were built, used diffie-hellman-group1-sha1, and the version of openssh no longer will accept that exchange, hence the error. To understand why this all came about, you can read about the Logjam exploit which attacked the SHA1 key exchange, as well as recommended configuration changes to a variety of commonly used services. While openssh was not specifically vulnerable to logjam, given its focus on openssl, there was still a concern that the key exchange had a weakness, so support for diffie-hellman-group1-sha1 was removed from openssh. This page has more specifics. So at this point, you should be able to remedy the problem with an upgrade of libssh2 to a more modern version (version >= 1.7) which supports newer key exchange methods. One alternative to the reliance on the php extension would be to modify your code to use phpseclib instead, which supports modern servers.
-
I'm with @requinix -- Webalizer is pretty much a dead product. I believe that AWStats is the defacto standard FOSS web log reporting tool, being that it is typically bundled with CPanel. It's probably the closest thing to what Webalizer was, only it continues to be maintained and enhanced. It's a package of perl scripts, and is highly portable, as it mainly requires perl, and has documentation for installation, and in your case, has a windows installer. There are many log analysis systems that go far beyond the web, and for that reason, are often used instead of AWStats, and of course a lot of people just use google analytics or commercial alternatives. Most large commercial websites use multiple services to provide different types of analysis, including bug logging, which is not something traditional web analytics products try to track or categorize. With that said, there are numerous alternatives to awstats you might want to investigate. GoAccess is one that I'd recommend looking into. It also has to be said, that these products go through your http logs, and as the old saying goes, are subject to the possibility of GIGO (garbage in/garbage out), by which I mean, that they work with the data available to them in the http logs. In many cases, the default settings for apache or IIS are not sufficient to support accurate or enhanced reporting, depending on your environment. Often you need to modify the log format (as in for example, using enhanced log format) and/or creating a custom log format, that bakes in data specific to your system like specific cookies or non-default client IP settings. That's up to you, as well as automating ingestion of log files, or movement of log files from another server to an intranet or your workstation.
-
Oracle database has been around a long time, and has a lot of features and extensions that are specific to it. If you are not going to use it immediately, or need a certification for a job, I wouldn't recommend going down that rabbit hole, even though I do think that Oracle database is a great RDBMS in many ways, but it is commercial and expensive. You often see it paired with java/enterprise java applications. For reasons I won't go into, besides cost, very few people pair PHP with Oracle database. The open source database closest in design and features to Oracle is Postgresql, so if anything, exploring postgresql would be a step in that direction. Since you use SQL Server, I would suggest getting certs in that, and in particular, learn about the specific things you listed, like transactions and concurrency (locking), and Views, stored procedures and triggers. Sprocs and Triggers are very important and highly used in SQL server development (Transact-SQL aka T-SQL), and in Oracle (which has an entirely different stored procedure language). MySQL also has stored procedures & triggers, but they are not commonly used, in comparison to the way that they are very often baked into applications that use sql server on the backend, as is the case with a lot of .NET applications. I don't think you can really say you are confident in your SQL knowledge until you are confident in the many ways you can use joins (including self joins), and the use of grouping and aggregation, as these are some of the primary reasons people use relational databases. It also helps to learn about the way rdbms's work in terms of datatypes, constraints and indexes. You want to have a good working understanding of the different types of indexes and the ways they overlap with primary key/unique constraints. You also really need to understand concurrency and locking, as it pertains to each database, and an understanding of transactions as well as "2 phase commit" support. While all the major relational database engines have configuration options that can be used to alter the concurrency/locking models, MySQL (and forks like MariaDB) is particularly different in that it allows for the use of different engines. For example, the original MySQL engine (myisam) is very different from the popular InnoDB engine that most companies use. It's a simple example, but MyISAM has no support for transactions, so you can write code that starts transactions and commits or does a rollback, and mysql will happily except that code, when in fact it actually ignores those statements entirely and doesn't support transactions whatsoever. You also want to understand how you install and configure these databases, and what options and tradeoffs might be involved in how you set them up. This affects how a database might/might not recover from a crash/ lose some data/transactions (or not), have backup options, or support replication in various flavors. With the existence of Docker, it's now much easier to experiment and learn about these databases, and create local test configurations. I think it helps to keep in mind, that there are categories of developers (DB Architects & Administrators & DB developers) who specialize in these products, and they have extensive levels of depth to them. There are some well known experts with books you might be interested in. A couple off the top of my head, are Joe Celko, who wrote some well known SQL books, and Tom Kyte, who authored many books on Oracle, and was well known for his "Ask Tom" column where he answered oracle questions and demonstrated ways certain problems could be solved. PHPFreaks is fortunate to have a number of developers who have consistently shared their expertise with relational database design and SQL, so this is still a great place to get advice and in many cases example code.
-
One of the benefits of the PHP ecosystem is that it has not one, but 2 of the best web application MVC frameworks in existence, those being Laravel and Symfony. I've used both and either one is a great starting point for creating a web application. I have created or worked on large applications in both frameworks, although I will admit that I'm biased towards Symfony. Symfony is typically paired (and somewhat bundled) with the Doctrine ORM, but Doctrine can be used independently in a project. What is more, Doctrine has several components, including a "Database Abstraction Layer" aka DBAL, that provides a nice wrapper around PDO. Not too long ago, I created a little proof of concept app, based on a forum question, and I put this web application on github, and I reference it now, because it was made using DBAL. It's an example of a simple web app that only uses 3 components, with the primary one being the DBAL wrapper. It also illustrates some best practices, in terms of where to put custom classes, what sort of minimal directory structure your project(s) should have, an implementation with a quasi-front controller, and composer for downloading components and autoloading. I also used the CSS framework Bulma. I'd suggest git cloning it, and poking around in the code. You could also experiment with adding some components, or unit tests. With that said, once you consider what a larger projects would need, not to mention the lack of routing, or views, before long it becomes pretty apparent that you're just better off getting the MVC from Symfony or Laravel. Template engines like Twig or Laravel's Blade have some great features like partials, helpers and template overrides (which are sort of like child classes for templating) that go a long way for separating concerns. Certainly, you can create your own framework, as many others have done, but by the same token, most home grown frameworks, end up implementing some form of MVC anyways.
-
This is usually simple. At this point I think people need to see all your code. Ideally you could put it in a github repo, but an alternative would be to post it to a pastebin like this one: https://forum.gizmola.com/pastebin
-
It's been an ongoing process by Google to remove search terms from these reports for while now. They basically started replacing the actual keyword terms with "not provided". I guess I inadvertently necro'd this old topic, but at least when search engines index this thread, we'll have some discussion of it now. Google's documentation explicitly states that they stopped providing the keyword information, because it was a privacy issue, at the point that these searches were happening within the confines of SSL connections. I've also seen SEO people who have opined that this decision also helps Google obfuscate the value of search terms since they make money selling placement, but that's just conjecture.
-
The column(s) you select will generate one row(group) per unique value of that column. Simple example of orders, assuming the order contained a column for the country_code of the customer that placed the order. You want a result with the "Total value of orders by country". So you would want to GROUP BY country_code. Your result set will then have 1 row for each country, but a SUM(amount), of course will provide you the total value of orders for that country. Let's say instead, you want a sum of orders by country, but you want the total for that country by year. SELECT country_code, YEAR(order_date) as year, SUM(amount) FROM ORDERS GROUP BY country_code, YEAR(order_date) ORDER BY country_code, year At that point you're going to get a row for every country_code/year combination, and the SUM(amount) is relative to that grouping.
-
You won't get one answer because conventions vary by linux distribution can vary by shell bourne shell tends to be a base System scripts do things at boot time and runlevel changes bash is a backwards compatible with sh, but has many extra features Config works with sh/bash/ksh/csh, but anything you do should be bourne shell syntax Other shells have become popular, and are even the default on newer os's (as in OSX now defaulting to zsh) If you're using a newer shell like zsh or fish, then they typically have their own config files you need to research Long story short: Read the /etc/profile script and the /etc/bashrc script. Often one or both will include scripts in a directory like /etc/profile.d If that is already working, you should place scripts that customize things for all users in that directory rather than modifying the /etc/profile or /etc/bashrc script directly. Individual settings should be done in the user's home directory use ~/.profile or ~/.bashrc Aliases are not part of the bourne shell, so you are utilizing a shell specific extension Bash often supports other files like ~/.bash_aliases As for types of shells: Login shell facilitates login, and will run commands in the files mentioned previously An interactive shell is connected to a tty so that the user can interact with it. It will also have certain default settings like job control enabled A non-interactive shell is used for scripts, since the user will not be interacting This old serverfault thread provides a good summary of the configuration files loaded.
-
Are you doing a session_start() in baglan.php? If you are, then you should not be doing it again in the scripts that have already included baglan.php.
-
You can frequently achieve the same layout with flexbox or grid. If you are looking to implement a true grid, then grid is better suited to that. I feel like I have suggested this to you before, but this video does an excellent job showing the differences and suggesting when to use one vs the other.
-
my query is not sorting the second SELECT when using UNION and ORDER BY
gizmola replied to jasonc310771's topic in MySQL Help
This type of use case is exactly why people use caching servers like redis or memcached, although you can also support the requirement, with in some cases, edge side includes or client side includes (using javascript). With something like redis, the basic idea is this: Code checks redis for existence of top 10 result. If not found, then query writes cached version with new TTL. You can use a cron job to regenerate the cache at whatever interval you want. Pretty much every site that has a massive userbase implements caching. For a single/monolithic server, PHP has long had options like the shared memory routines, or APC that can be used as well. It's also possible to generate a snippet of html in a file that you read off the file system, as a simple "roll your own" method of caching. All of these techniques reduce the load on your database, which is often the first and most difficult bottleneck to overcome when lack of scalability starts to limit performance. -
I would suggest a simple name/password system, as is standard. What you can do is log the IP address in the database. The server gets access to the client IP address. The users have no way of knowing what you are logging or not in that regard. You can then write some reports that look for multiple logins from the same IP address, which should not happen from a mobile phone, unless the users are logging into the same wifi network. Another thing you could do is push a tracking cookie that doesn't expire. Generate a guid value or hash, and push this using some innocuous name, when a user logs in. Set the cookie so that it doesn't expire for 12 months or something like that. You can then check for the existence of this cookie and log it upon login. You can use that cookie, like IP address. In general these types of things require a login/audit table, that makes an entry for each user login. If the users don't understand what you're doing, you are likely to be able to find people logging into multiple accounts using the same cookie value, or missing the cookie on login. You 100% will know when a user logs in with the wrong cookie. What you choose to do in that circumstance is up to you, but I would not suggest that you make it an outright error, but rather something that is determined through reporting on the audit table. I would suggest that you employ both items (IP address and login cookie value), and perhaps a status code, you can set, when the code sees a user logging in with some other user's cookie.
-
<?php require_once('kaynak/baglan.php'); session_start(); echo '<pre>' . print_r($_SESSION, true) . '</pre>'; ?> <!DOCTYPE html> <html lang="tr"> <head> <title>Sayfanız - Hoşgeldiniz</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="kaynak/style.css"> </head> <body> <div id="ana"> <h1><?php echo $_SESSION['nik']; ?>Üye giriş sayfasına hoşgeldiniz</h1><br> </div> </body> </html> This is malformed -- you are outputting html before outputting a full html page. That is broken. If you want to do a debug statement like this with the <pre> make sure you move it inside your html page, in the body. <?php require_once('kaynak/baglan.php'); session_start(); ?> <!DOCTYPE html> <html lang="tr"> <head> <title>Sayfanız - Hoşgeldiniz</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="kaynak/style.css"> </head> <body> <?php echo '<pre>' . print_r($_SESSION, true) . '</pre>'; ?> <div id="ana"> <h1><?php echo $_SESSION['nik']; ?>Üye giriş sayfasına hoşgeldiniz</h1><br> </div> </body> </html>
-
It does appear this is intended to be a search so the where criteria needs to be implemented. Towards that goal, this is not going to work: <input type="text" name="search_query"><br> Followed by: $search = $_POST['search']; See the issue? (search_query is not search). This query is also not going to work as written: ...., date_stolen, location_stolen, found, date_found, location_found, other_information * Typically either enumerate the columns or use the wildcard '*', but certainly this syntax of 'other_information *' is invalid, as you would at very least need 'other_information, *'.
-
Indeed, your pattern should be something like RewriteRule ^page/(.*) /page.php?slug=$1 [L,QSA] Take care with the ^ and $ anchors as they may be more restrictive than you actually want.
-
Stopwatch (server side) to see from severals clients
gizmola replied to elsafraslastra's topic in PHP Coding Help
@UmarFarooq Explain how that code in any way helps with what the user asked for. Where did you get this code from? Why didn't you put it in a code block? Where is the explanation of what the code does?