-
Posts
15,288 -
Joined
-
Last visited
-
Days Won
436
Everything posted by requinix
-
Best way to add noindex header tag to robots.TXT files
requinix replied to Abhishekdhruw's topic in PHP Coding Help
Which is...? -
https://betterprogramming.pub/how-not-to-ask-questions-on-the-internet-72dd30e273a7
-
Play a m3u8 stream from url in local .txt file
requinix replied to MikePer's topic in PHP Coding Help
file_get_contents is probably the right solution. What was the code you had that tried to use it, what happened when you ran it, and what did you expect to happen? -
Implications of final classes and final constants
requinix replied to NotionCommotion's topic in PHP Coding Help
It's one of those things that isn't harmful per se - it's redundant, really - but if someone wrote it then they could be making a mistake in some other sort of way. -
Implications of final classes and final constants
requinix replied to NotionCommotion's topic in PHP Coding Help
private + final doesn't make sense: if it's private then nothing can override it anyway. Just make it private. -
Hmm, looks like you'll need a modification or two to the array I suggested. More like array( 13763 => array( "base_image" => "13763.jpg", "additional_images" => array( "13763-1.jpg", "13763-2.jpg" ) ), 0. Start with an empty array for you to store the lists of additional files you'll be building. 1. Use glob() to get the list of files. It already comes sorted in ascending order, you need it sorted in ascending order, and I'm not sure why you want to sort it in reverse order. 2. Use pathinfo() to get the different parts of the file name. Look at the different parts it returns because you'll want more than one of them. 3. If the filename-without-extension portion is just a number then add an entry to the array. You know the base_image value already. Start with the additional_images empty. 4a. If the filename-without-extension portion is not just a number then split it into (1) the initial number and (2) the hyphen and everything after it. 4b. Look for an entry in the array for the number. If it exists then add the file to the additional_images array. If not then I don't know what you want to do. At the end of this, you should have an array that looks like the sample above...
-
I think I'm getting an aneurysm. What you're describing does not seem to match what the screenshot of the file shows. I think what you actually want to do is (1) find all the files in the directory, (2) group them by the initial number in the name, then (3) sync up the CSV file according to the new set of files. But what to do with files in the CSV that aren't in the directory? Seems you want to discard them? So one step at a time. You need to get an array - one that is not $additionalImages but something entirely different - which has a list of all the files grouped by that initial number. With your example, it will look like array( "13763.jpg" => array( "13763-1.jpg", "13763-2.jpg" ), "13764.jpg" => array( "13764-1.jpg", "13764-2.jpg" ), "13765.jpg" => array() ) That means there is a 13763.jpg with two additional files, 13764.jpg with two more additional files, and 13765.jpg without any additional files. Once you have that then you can move onto the next step of writing it to the file...
-
Use $_GET or $_POST to get a value from the form. If you're being tested on being able to do things like use cURL for API requests then I assume that handling form data was covered in earlier lessons.
-
Correct. Consider how you'll be using this table and how often. When will you need to read it? When will you need to write to it? Writing is infrequent: when a user views a thread. Humans don't do that at any kind of speed a computer might consider "fast". Open a few tabs at a couple per second, then stop while they read. That's nothing. But reading, that's a lot more frequent. You'll need it for thread listings (what's read and what isn't), probably for thread viewing (mark where "new" content starts), perhaps for daily tasks. Still not exactly a large volume, but the point is it's much more frequent than reading. So the conclusion? Go ahead and sacrifice some write performance if it gains you read performance. I'm thinking CREATE TABLE whatever ( id bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, user_id bigint unsigned NOT NULL, thread_id bigint unsigned NOT NULL, last_read DATETIME NOT NULL, UNIQUE (user_id, thread_id) ) ENGINE=MyISAM;
-
It'll be a lot more useful if you can track not just whether they've read the thread but whether there have been any new posts since then. Because if I read a thread and someone adds to it later, now I haven't read the thread anymore. Grow long? Yes. Grow relatively fast? Yes. Be a problem? No. Database systems are designed for this sort of thing, and with good design on your part (especially indexes) a large table won't be any problem at all. At least not for mortals like you and me - grow to Facebook scale and we'll have to revisit this. You can also consider a "mark all as read" feature that will help here. You store a timestamp with the user, that applies to either the entire site or to just one subforum, that tracks the last time they hit the "mark all as read". Checking if a thread has been unread or not is a two-step process of checking (1) whether the most recent timestamp for it is after the mark-as-read timestamp then (2) the thread's most recent post is not recorded in the has-previously-read table. Which means that if/when the user hits the button you can also zero-out their records in the read table.
-
How to get Seo friendly URL in search bar in php
requinix replied to jadprash's topic in PHP Coding Help
Search engines stopped caring about URL structures years ago. As long as you have the appropriate words in there, like "search" and the search keywords, then it's fine. -
SQL syntax error (using SELECT FROM INNER JOIN ON WHERE)
requinix replied to yuanven's topic in PHP Coding Help
No it is not. Look at the query in your code: $query = "SELECT krs.id_thn_ak ,krs.kode_matakuliah ,matakuliah.nama_matakuliah ,matakuliah.sks ,krs.nilai FROM krs INNER JOIN matakuliah ON (krs.kode_matakuliah = matakuliah.kode_matakuliah) WHERE krs.nim = $nim AND krs.id_thn_ak = $thn_ak"; Look at the query in the error message: SELECT krs.id_thn_ak ,krs.kode_matakuliah ,matakuliah.nama_matakuliah ,matakuliah.sks ,krs.nilai FROM krs WHERE krs.nim = 18024114 AND krs.id_thn_ak = INNER JOIN matakuliah ON (krs.kode_matakuliah = matakuliah.kode_matakuliah) They are not the same query. Now look at this part of the query that was shown in the error message: ...FROM krs WHERE krs.nim = 18024114 AND krs.id_thn_ak = INNER JOIN matakuliah... See why the query does not work? Now look at this part of your code: $this->input->post('$id_thn_ak', TRUE); Look carefully. Are you sure that is correct?- 1 reply
-
- 1
-
-
Mini php search engine, order with the search term
requinix replied to oz11's topic in PHP Coding Help
You need to rank the results, not just check if they contain the words in the query. Try a FULLTEXT search using MATCH AGAINST. https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html -
The general term is "CAPTCHA". Google's reCAPTCHA and whatever the non-Google alternative is, are the de-facto standards. It takes a little more work to implement but they're effective and reliable.
-
Sounds like you're talking about doing this in Javascript? If you're implementing your own bot check then it can't be in Javascript because the bots can just ignore that. It has to be in PHP. Doing that means you need to "remember" $entry from before. If you put that as a hidden input in the form then guess what the bots will do. There's a really simple way to solve this, though. Don't remember $entry but a hash of it, then check the hashes. $hash = sha1(__FILE__ . $entry); <input type="hidden" name="hash" value="<?= $hash ?>"> Then your PHP does the hash the same way but using the number the user put in the form, and it checks that the result matches the hash from the form. Bots can't figure out what value generated the hash, which also means they can't successfully substitute their own hash value. But know that bots are capable of solving math problems like this...
-
Python people love to say it's better/faster/whatever than <other language>. Don't take their word for it.
-
Like I asked elsewhere, What have you tried so far?
-
What mac_gyver and Barand are trying to tell you is that this idea you have is the wrong way of doing... whatever you want. As in, don't use multiple arguments named "varX" and instead use a single argument that takes an array. xyz(1, 2, 3); // no xyz([1, 2, 3]); // yes
-
Please confirm you are a human being living and working in Australia before we continue.
-
I don't see OAuth2 mentioned in https://secure3.saashr.com/ta/docs/rest/public
-
Yes it can because I'm pretty sure you have not installed Laravel correctly. No it is not.
-
https://laravel.com/docs/9.x#your-first-laravel-project
-
...Why are you trying to provide a link to some place on mail.google.com that almost certainly does not exist? And is this a really old application that you're maintaining? Because it's using PHP 4-style code, and that version died off 14 years ago. Like, you aren't even using class autoloading. I don't know what you're trying to say, because what it does sound like you're trying to say doesn't make any sense, but the answer is very likely something along the lines of: We don't know what $request is or what its "url" method is. You have to learn about that method and see if there's a way to call it so that it does not include the URL scheme (http/s) or domain (localhost).
-
If there is a minus sign then either (a) the "prefix" is a minus sign or (b) your rounded number is negative. There's no way for me to know which one based on what you've posted.