Jump to content

guymclarenza

Members
  • Posts

    64
  • Joined

  • Last visited

Contact Methods

  • Website URL
    https://dustfactory.co.za

Profile Information

  • Gender
    Male
  • Location
    Centurion, South Africa
  • Interests
    Travel, Bikes, Cars, Books, Learning, Wood, Dad stuff
  • Age
    57

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

guymclarenza's Achievements

Regular Member

Regular Member (3/5)

2

Reputation

2

Community Answers

  1. I have a problem here, this script works with the exception of showing the correct days with the date Result can be seen at https://centurionphotographer.co.za/booking/ AI just gives me one different problem after another and I am not a good enough coder to solve the problem. // Number of months to display $monthsToShow = 3; // Get the current date and time $currentDate = date('Y-m-d'); // Calculate the start and end dates for the calendar $startDate = date('Y-m-d', strtotime($currentDate)); $endDate = date('Y-m-d', strtotime($currentDate . ' + ' . ($monthsToShow * 30) . ' days')); // Prepare the SQL statement to retrieve availability $availabilityQuery = $pdo->prepare(" SELECT avdate, COUNT(*) AS available_slots FROM availability WHERE avdate BETWEEN :start_date AND :end_date GROUP BY avdate "); // Prepare the SQL statement to retrieve bookings $bookingsQuery = $pdo->prepare(" SELECT bkdate, COUNT(*) AS booked_slots FROM bookings WHERE bkdate BETWEEN :start_date AND :end_date GROUP BY bkdate "); // Generate the calendar $currentMonth = ''; echo '<table>'; // Loop through each day within the specified range for ($date = $startDate; $date <= $endDate; $date = date('Y-m-d', strtotime($date . ' + 1 day'))) { $currentMonthOfDate = date('F Y', strtotime($date)); $dayOfWeek = date('w', strtotime($date)); // Check if a new month has started if ($currentMonth !== $currentMonthOfDate) { $currentMonth = $currentMonthOfDate; echo '<tr><th colspan="7">' . $currentMonth . '</th></tr>'; echo '<tr><th>Sunday</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th></tr>'; } // Check availability for the current date $availabilityQuery->bindParam(':start_date', $date); $availabilityQuery->bindParam(':end_date', $date); $availabilityQuery->execute(); $availabilityResult = $availabilityQuery->fetchAll(PDO::FETCH_ASSOC); // Check bookings for the current date $bookingsQuery->bindParam(':start_date', $date); $bookingsQuery->bindParam(':end_date', $date); $bookingsQuery->execute(); $bookingsResult = $bookingsQuery->fetchAll(PDO::FETCH_ASSOC); // Determine the class to apply based on availability if ($availabilityResult && $availabilityResult[0]['available_slots'] > 0) { $class = 'available'; $link = '<a href="timeslots.php?date=' . $availabilityResult[0]['avdate'] . '">Check available timeslots</a>'; } elseif ($bookingsResult && $bookingsResult[0]['booked_slots'] > 0) { $class = 'fully-booked'; $link = 'Fully Booked'; } else { $class = 'unavailable'; $link = ''; } // Output the date with the appropriate class and link echo '<td class="' . $class . '">' . $date . '<br>' . $link . '</td>'; // Start a new row after Saturday if ($dayOfWeek == 6) { echo '</tr><tr>'; } } echo '</table>';
  2. This function parses the input using an HTML 4 parser. The parsing rules of HTML 5, which is what modern web browsers use, are different. Depending on the input this might result in a different DOM structure. Therefore this function cannot be safely used for sanitizing HTML. As an example, some HTML elements will implicitly close a parent element when encountered. The rules for automatically closing parent elements differ between HTML 4 and HTML 5 and thus the resulting DOM structure that DOMDocument sees might be different from the DOM structure a web browser sees, possibly allowing an attacker to break the resulting HTML. Seems like that is not a fantastic option
  3. This function is not working but I need some addd info from the function, Assume $content is populated, I want to count outbound links, ie links going to another website and internal links those staying on the website but going to another page. I also want to list said links by outbount and internal with link text and url., It would also be nice if I could at the same time fail or pass link text if neccessary, If linktext is "click here" or something equally non descriptive it would be marked with a red cross, or green tick if good, Why is this not working? and how do I make the neccessary changes to the script to add the functionality function checkLinksForDescriptiveText($content) { // Example: Check links for descriptive link text preg_match_all('/<a [^>]*href=["\']([^"\']+)["\'][^>]*>([^<]+)<\/a>/i', $content, $links); $total_links = count($links[1]); $descriptive_links = 0; foreach ($links[2] as $linkText) { $linkText = strip_tags($linkText); if (strlen($linkText) > 0 && strlen($linkText) < 50) { $descriptive_links++; } } return [$total_links, $descriptive_links]; }
  4. Thank You, now lets see if I can make the next thing work.
  5. I am an amateur php coder at best, yet I muddle through and make stuff work mostly, So this is not crashing, but all I am getting as an answer is the header and my this is not working, what am I doing wrong here? The fact that it is not throwing up an error is already a win, I have checked, $content exists. <?php function validateURL($url) { return filter_var($url, FILTER_VALIDATE_URL); } function fetchURLContent($url) { $content = @file_get_contents($url); return $content !== false ? $content : false; } function analyzePage($url) { $analysis = []; $url = validateURL($url); if ($url) { $content = fetchURLContent($url); if ($content !== false) { $analysis['page_size'] = getPageSize($content); //$analysis['page_speed'] = getPageSpeed($url); } } } function getPageSize($content) { // Example: Calculate and return the page size return number_format(strlen($content) / 1024, 2) . ' KB'; } /*function getPageSpeed($url) { // Example: Calculate and return the page load time $start_time = microtime(true); $content = fetchURLContent($url); $end_time = microtime(true); $load_time = ($end_time - $start_time) * 1000; return number_format($load_time, 2) . ' ms'; } function getPageRequests($content) { // Example: Count and return the number of page requests preg_match_all('/<img [^>]*src=["\']([^"\']+)["\']/i', $content, $images); return count($images[1]); } */ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $url = $_POST['url']; $analysis = analyzePage($url); if (isset($analysis['error'])) { echo "<p>Error: {$analysis['error']}</p>"; } else { // Output analysis results here... echo "<h1>Test</h1>"; foreach ($analysis as $key => $value) { echo "<p>$key: $value</p>"; } } echo "This shit is working but not"; } else { ?> <h1>Test</h1> <form method="post"> <label for="url">Enter URL: </label> <input type="text" name="url" id="url" required> <input type="submit" value="Analyze"> </form> <?php } ?>
  6. Thanks to everyone that tried to help, I have been busy with my real job. Making wooden stuff. I found the solution and my site now works under php8.1, hopefully I never need to do this again unless I feel like making a change. If you want to see the site it's at DustFactory <? wasn't doing it, I had to make all instances <?php
  7. $sqli= $pdo->query("SELECT * FROM pages WHERE page_website='".$site."' ORDER by page_id ASC LIMIT 0,1"); while ($rowi = $sqli->fetch()) { $bid=$rowi["page_id"]; $img=$rowi["page_img"]; $imga=$rowi["page_imgalt"]; $title=$rowi["page_title"]; $pge=$rowi["page_text"]; $pint=$rowi["page_intro"]; $ptop=$rowi["page_banner"]; $pvid=$rowi["page_video"]; $tags=$rowi["page_tags"]; $metadesc=$rowi["page_desc"]; $ontology=$rowi["page_onto"]; $ontodesc=$rowi["page_ontodesc"]; } Gives me this as a result on page. In my limited understanding it would seem that pdo->query no longer gives the desired results in php8. This works in php7. I seem to be too stupid to find why this is. Can anyone point me in the right direction please.
  8. I have a working website that I need to upgrade to php 8 or whatever is latest, Is there some kind of script or app that can be used to check my existing script and tell me what is breaking it? Alternatively, where can I see a list of deprecated tags that need to be changed to become compliant. I am not a beginner but I don't do php full time, my main job is making stuff with wood.
  9. public function getFaq($site) { $sql = "SELECT faq_cats.faqc_name, faqs.faq_id, faqs.faq_question, faqs.faq_answer FROM faq_cats INNER JOIN faqs ON faq_cats.faqc_id = faqs.faq_cat WHERE faq_cats.faqc_site = ? ORDER BY faq_cats.faqc_name"; $stmt = $this->connect()->prepare($sql); $stmt->execute([$site]); $fcid = $stmt->fetchAll(); $fhead = null; $findex = null; $fcont = null; echo "<h1>FAQ Index</h1>"; foreach ($fcid as $faq) { $fname = $faq["faqc_name"]; $fquest = $faq["faq_question"]; $fans = $faq["faq_answer"]; $faid = $faq["faq_id"]; if ($fhead != $fname) { $findex .= "<h2>".$fname."</h2>"; } $findex .= "<a href=\"#".$faid."\">".$fquest."</a><br />"; $fhead = $fname; } foreach ($fcid as $faq) { $fname = $faq["faqc_name"]; $fquest = $faq["faq_question"]; $fans = $faq["faq_answer"]; $faid = $faq["faq_id"]; $fcont .= "<a name=\"".$faid."\"></a>".$fquest."<br />".$fans."<br /><br />"; } echo $findex; echo "<br /><br />"; echo $fcont; } } $faqob = new getData(); $faqob->getFaq($site); Is there a shorter or more concise way of doing this? The result looks like this FAQ Index DNA Testing FAQs What should I do with unexpected DNA results? How can I learn more about DNA and how to use it? What should I consider before testing my DNA? What is DNA? Genealogy FAQs What is the difference between my family tree and my genetic tree? What types of DNA are tested for ancestry purposes? Paternity Test FAQs How do I receive my results? How long do I have to wait for my paternity test results? How long will the paternity test take? How is the paternity test done? If the mother is deceased or does not want to come, what can we do? Does the mother have to be present? What should I do with unexpected DNA results? If you receive unexpected results, such as the identity of parents, grandparents, great-grandparents, or other previously unknown relatives, be sensitive and considerate of others involved who may be affected by the results. Approach family members with c How can I learn more about DNA and how to use it? Consider these resources in learning more about DNA and how you can use it effectively in your own family history activities: ISOGG Wiki—The International Society of Genetic Genealogists has created and maintains a wiki (community written encyclopedia) What should I consider before testing my DNA? DNA test results may reveal unexpected information about your family history, such as adoptions, unexpected paternity, etc. The affected party may be yourself or a close DNA relative—perhaps someone you know nothing about. If this new information may be u What is DNA? DNA, or deoxyribonucleic acid, is the genetic code that defines each person’s biological characteristics. DNA is chains of four individual nucleotide links, the sequence of which encode our genetic information. These strings of DNA are coiled into package What is the difference between my family tree and my genetic tree? Your family tree is what has been documented over time through family history records and often reflects relationships, some of which may not be biological. Your genetic tree consists of the relatives with whom you share DNA, which you mutually inherited What types of DNA are tested for ancestry purposes? DNA can provide information in different ways to help you identify your related family members and ancestors, depending on which part of the DNA molecule is used. Typically, four types of DNA are used to discover more about your ancestry: atDNA Autoso How do I receive my results? You have options to choose from that you indicate on the form How long do I have to wait for my paternity test results? Approximately 10-15 working days How long will the paternity test take? The test itself takes approximately 150 minutes How is the paternity test done? a Finger prick of the parties involved to collect a small blood sample If the mother is deceased or does not want to come, what can we do? If the mother is still alive but does not want to be present for the test, an affidavit is required explaining why she is not present. The affidavit must be brought with the other parties. If the mother is deceased, then the death certificate of the mo Does the mother have to be present? If the child is a minor (younger than 18 years), the mother needs to be present to sign consent for testing for the minor child. If the child is older than 18 years, the mother need not be present.
  10. This does not work public function getFaq($site) { $sql = "SELECT faq_cats.faqc_name, faqs.faq_question, faqs.faq_answer FROM faq_cats INNER JOIN faqs ON faq_cats.faqc_id = faqs.faq_cat WHERE faq_cats.faqc_site = ? ORDER BY faq_cats.faqc_name"; $stmt = $this->connect()->prepare($sql); $stmt->execute([$site]); $fcid = $stmt->fetchAll(); $fhead = null; foreach ($fcid as $faq) { $fname = $faq["faqc_name"]; $fquest = $faq["faq_question"]; $fans = $faq["faq_answer"]; $fcont = null; if ($fhead != $fname) { $fcont .= "<h2>".$fname."</h2>"; } $fcont .= $fquest."<br />".$fans."<br /><br />"; $fhead = $fname; } } } $fcont; $faqob = new getData(); $faqob->getFaq($site); echo $fcont; This does Class GetData extends Dbh { public function getFaq($site) { $sql = "SELECT faq_cats.faqc_name, faqs.faq_question, faqs.faq_answer FROM faq_cats INNER JOIN faqs ON faq_cats.faqc_id = faqs.faq_cat WHERE faq_cats.faqc_site = ? ORDER BY faq_cats.faqc_name"; $stmt = $this->connect()->prepare($sql); $stmt->execute([$site]); $fcid = $stmt->fetchAll(); $fhead = null; foreach ($fcid as $faq) { $fname = $faq["faqc_name"]; $fquest = $faq["faq_question"]; $fans = $faq["faq_answer"]; $fcont = null; if ($fhead != $fname) { $fcont .= "<h2>".$fname."</h2>"; } $fcont .= $fquest."<br />".$fans."<br /><br />"; $fhead = $fname; echo $fcont; } } } $fcont; $faqob = new getData(); $faqob->getFaq($site); Can anyone tell me why and how to make the previous one work.
  11. I want to reuse the data from getFaq for different levels of a website. $fcid is the variable. Creating the full page in the getFaq function could work but limits the function to one set of results, Do I need to create a new function if I want to create another page with the data and a new call to the database? It seems to me there must be a way to store the array from $fcid and call it from another page to get a subset of the data. I added the getFP class as an attempt to do just that but I am getting no results. If I place the code in the getFP class in the getFAQ function the script works as envisioned. I want to create a getFAQpage, a getFAQheader and a getFAQsubset based on categories. The data is all there in $fcid but I have no idea on how to access it from outside the class. Dbh is the PDO connection. Class GetData extends Dbh { public function getFaq($site) { $sql = "SELECT faq_cats.faqc_name, faqs.faq_question, faqs.faq_answer FROM faq_cats INNER JOIN faqs ON faq_cats.faqc_id = faqs.faq_cat WHERE faq_cats.faqc_site = ? ORDER BY faq_cats.faqc_name"; $stmt = $this->connect()->prepare($sql); $stmt->execute([$site]); $fcid = $stmt->fetchAll(); return $fcid; } } Class getFP extends GetData { public function getFaqPage([$fcid]) { $fcid = $this->fcid; $fhead = null; foreach ($fcid as $faq) { $fname = $faq["faqc_name"]; $fquest = $faq["faq_question"]; $fans = $faq["faq_answer"]; if ($fhead != $fname) { echo "<h2>".$fname."</h2>"; } echo $fquest."<br />".$fans."<br /><br />"; $fhead = $fname; } } } $faqob = new getFP(); $faqob->getFaqPage([$fcid]);
×
×
  • 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.