Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/02/2023 in all areas

  1. https://enb.iisd.org/_inc/simple_html_dom/manual/manual.htm
    1 point
  2. There isn't a list of values for nodeName because the list would be infinitely long. The nodeName is the tag name in the source code. Since the code is interested in Sitemap files, and the root element of those files is either <sitemapindex> or <urlset> then you'll be looking for a nodeName of 'sitemapindex' or 'urlset'.
    1 point
  3. Something like this: $xml = file_get_contents($sitemapUrl); $dom = new DOMDocument(); $dom->loadXML($xml); if ($dom->nodeName === 'sitemapindex'){ //parse the index } else if ($dom->nodeName === 'urlset'){ //parse url set } else { //some other xml file } But ChatGPT is, apparently.
    1 point
  4. Checking the extension is pointless. Extensions don't necessarily mean anything, and many URLs these days do not even have extensions to check. Trying to check the extension of a URL to determine if it's an XML file and then treat it as a site map is the entirely wrong approach here. Just because a URL ends in .xml doesn't make it a sitemap file, it could be any sort of XML file. What determines if something is a sitemap file is that the URL is part of a <sitemap> element, so that's what you need to check. If you look at the protocol page, you'll see there are essentially two types of sitemap files. A urlset listing all the URLs of the site, or a sitemapindex listing other site maps. So when you download an XML file, you should be checking whether the file is one of those two types and parse them accordingly. I'm not familiar enough with simplexml to know the code for that, but with DOMDocument you'd load the XML then check the nodeName to determine if it's a urlset or a sitemapindex.
    1 point
  5. None. I played around with ChatGPT a bit when it first came out, to see what it was capable of and just have some fun. I was impressed by it's ability to understand things. I fed it a few functions I've written and asked it to explain what the functions did and write sample code using the functions and it was surprisingly accurate. I don't really see much use for it day-to-day though, so I haven't really used it in quite a while. It does get a lot closer to the "Ask a question, get an answer" goal of search engines, which is why I immediately knew people would be working on that and am not at all surprised to see it happening. Eventually as the models get better and more integrated into search, you'll be able to just type a plain-English (or whatever language) question into google and get an actually answer back instead of having to wade through a list of result pages. From the code side of things, the AI is good enough right now to answer simple syntax / logic errors. Take one of the questions posted here as an example. I told ChatGPT what the error was, what the code was, and to tell me why. It responded: I imagine eventually such a tool will be used to help teach new programmers by either providing better error detection in IDE's or having an virtual mentor they can ask questions and get immediate answers rather than having to either search the web or post on a forum and wait for a response. There are already AI coding assistants that might fulfill this task, I haven't tried any of them personally to know how useful they are.
    1 point
  6. Actually this is beginner level. You start with a directory structure something like: /functions /html index.php search.php register.php bootstrap.php Where index.php, search.php, register.php are the files users will visit like http://website.com/search.php and http://website.com/register.php Inside search.php and register.php the code will look something like: // defines constants like DB_USER, DB_PASS, DB_HOST, .. so you only need to change this in one place require __DIR__ . '/bootstrap.php'; // load functions you need require APP_PROJECT_DIR . '/functions/page_functions.php'; require APP_PROJECT_DIR . '/functions/search_functions.php'; // do the work // load the HTML require APP_PROJECT_DIR . '/html/search_view.php'; Using this way of working you avoid having a big wall of text and give each file their own responsibility.
    1 point
  7. I use chatGPT as a tool. For programming I just use it to help with the coding, but I have found out that it's reasoning skills is limited. What I mean if you don't know how to code it will go astray and leave you in even more confused. It also doesn't know the best coding practices especially when it comes to security. I have also stumped it a few times where ChatGPT will just leave you hanging. I find out it's best when you know how to code and just steer it in the right direction and go to forums like this to get help from a real human. Where it really shines well at least for me is rewording my comments as I'm not the greatest when it come to my grammar. Here's an example of what I'm saying - I utilize ChatGPT as an aid, primarily for assistance with coding. However, I've discovered that its reasoning capabilities are somewhat restricted. In other words, if you lack coding knowledge, it may lead you astray and create further confusion. Moreover, ChatGPT isn't well-versed in best coding practices, particularly regarding security. There have been instances when it left me hanging without a solution. I've found that it works best when you have coding knowledge and can guide it in the right direction while seeking additional support from real humans on forums like this. Where ChatGPT truly excels, at least for me, is in rephrasing my comments since I'm not particularly skilled in grammar.
    1 point
  8. Hi, It won't take you 6 years to understand OOP. OOP is about ownership and responsibility. Procedural is about functionality. From a procedural point of view a user is an array with certain fields like id, username, password, ... Any function can freely use, modify, or even remove these fields as they see fit. Nobody owns the data, and so anything can do to it what it wants. In OOP you assign a class with the ownership and responsibility of this data: class User { private ?int $id = null; private string $username; private string $password; } In the above example the User class owns the data, and doesn't allow anyone to touch it. Not very useful. class User { private ?int $id = null; private string $username; private string $password; public function changeUsername(string $username) { assertLength($username, 8); assertNotProfane($username); assertNotSameAsFirstOrLastName($username); assertNotSameAsEmail($username); $this->username = $username; } } Now the User class allows changing the username, if ALL requirements are met. Otherwise it will throw an Exception. Exceptions are a big part of OOP, it ensures your code follows a controlled path, like an assembly line, any bad items are cast to a different line. The advantage of encapsulating data is that there is only one place that controls access to the data, and not hundreds of places. So that if your requirements change, you can make the change in one place and not spend weeks tracking down all uses. I am not saying you should switch to OOP, just that it won't take you 6 years as the concept is quite simple.
    1 point
  9. $mail->SMTPSecure = "PHPMailer::ENCRYPTION_STARTTLS"; should be this I believe $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; Incorrect URL <a href='http://localhost/myproject/verify-email.php?token=$verify_token'>Click Me </a> Instead of using md5(rand()) for generating the password, you should use PHP's built-in password hashing functions like password_hash(). You have two calls to the sendemail_verify() function. Remove the first one (before the "send or not?" echo statement) as it is redundant and might lead to confusion. You are using $_POST['password'] as the value for the $verify_token variable. Instead, you should generate a random token using functions like bin2hex(random_bytes($length)).
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • 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.