Jump to content

jodunno

Members
  • Posts

    293
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by jodunno

  1. but you are using PHP Mailer. Interesting predicament. <?php require 'vendor/autoload.php'; use \Mailjet\Resources; ... i tried a Google search to find a good example: https://github.com/mailjet/mailjet-apiv3-php?tab=readme-ov-file#make-your-first-call
  2. Dear shadd, i sense that you are making this a publicly accessible script. Thus, i will agree that allowing anyone, bot, scraper, alien, dog or cat to run db code is a bad idea. if your script is in fact available to the public, then what else could we do? hmm. waiting for a lightbulb. still dark... still dark... wait, i see a flash... aha! maybe we can use a folder with a timestamp to illustrate persistence. You could make timestamps an event id. so i made a folder with a timestamp and added some cheap php code to show you how it works. You must think about what it is that you are trying to accomplish and attack it from every point-of-view. Eventually, you will come up with something that works. example folder name: 1726649294, which is a UNIX timestamp. <?php /* $ttl = (int) 7200; $ttl += time(); a formula for naming your folder. 7200 seconds = two hours the current name, 1726649294, is based upon the time that i created this example. 1726649294 may be expired when you test the code. so change the name of the folder to your current time using the aforementioned formula. */ echo 'event id: ' . basename(__DIR__) . '<br>'; ?> <!DOCTYPE HTML> <html> <body> <p id="demo"></p> <!--button onclick="countdownTimeStart()">Start Timer</button--> <script> // Set the date we're counting down to function countdownTimeStart(){ var x = setInterval(function() { let currentTime = new Date().getTime(); let countDownTime = new Date(<?php echo basename(__DIR__); ?>*1000); let timeElapsed = countDownTime - currentTime; // Time calculations for days, hours, minutes and seconds var hours = Math.floor((timeElapsed % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((timeElapsed % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((timeElapsed % (1000 * 60)) / 1000); // Output the result in an element with id="demo" document.getElementById("demo").innerHTML = hours + "h " + minutes + "m " + seconds + "s "; // If the count down is over, write some text if (timeElapsed < 0) { clearInterval(x); document.getElementById("demo").innerHTML = "EXPIRED"; } }, 1000); } window.onload = function () { countdownTimeStart() }; </script> </body> </html> otherwise, if your script is only available to logged in users, then follow the advice provided by maxxd and use the session storage.
  3. so you have some code to write...
  4. Unix timestamps utilize seconds. 60s * 3 = 180s three hours = 10800s. hello? https://www.php.net/manual/en/function.time.php "time(): int Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). " you should start your research with unix timestamps. https://www.unixtimestamp.com/ https://unixtime.org/ https://developer.mozilla.org/en-US/docs/Glossary/Unix_time I wonder, "why did i write a script with corrected JavaScript code when shadd ignores it?" your code is problematic. use the modified code and throw it in xampp.
  5. Are you still with us? requinix is a pro. You are in good hands. Meantime, margins is interesting because do you want margins or not? I see a double break after the body tag. <body><br><br/> incidentally, html5 does not require the ending slash. vide xhtml. since you are already using css, why not add margin control? <span style="font-family:'Comic Sans MS', Comic, Monospace; margin: 8px 8px"> the center tag is deprecated, is it not? Again, why not use css? align: center; text-align: center; let us know if you need further assistance. I will also post the entire script from the google drive link. I hope that it is okay to do so. Please forgive me if it is not okay to post the aftenrenlille.php code. <?php ini_set('default_socket_timeout', 5); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>AU-INFO</title> <style type="text/css"> #dagensret{ //font-size:10px; } .food{ // color: green; font-size:15px; } </style> </head> <body><br><br/> <span style="font-family:'Comic Sans MS', Comic, Monospace"> <center> <span style="font-size:25pt"> <?php // 11 // remember to remove the ; from the beginning of extension=php_soap.dll in php.ini $cli= new SoapClient('https://xxxxxxxxxxx.dk/SPService.asmx?WSDL'); //$res = $cli->__soapCall('DagensMenu',array()); // $xmlstr = $res->DagensMenuResult->any; $simple = simplexml_load_string($xmlstr); $text = $simple->Menu->Tekst; echo "AFTENRENGØRING "; echo $text.""; ?> <!--Overskrift--> <span style="font-size:10pt"> <!--Overskrift--> <!--Vegatare--> <span style="font-size:25pt"> <!---> <?php $simple = simplexml_load_file('https://xxxxxxxxxxx/SPService.asmx/AktuelleOmraadeRengoering'); $text = $simple->Aktivitet->Navn; // slette + tegn AU $text = str_replace('+', '', $simple->Aktivitet->Navn); echo $text; ?> </body> </html> <!--Menu herover--> </html>
  6. Timeout! How do you intend to prevent server-side regeneration? id est, where do you retrieve that hidden input timestamp from? one must create persistent/long-term storage such as a database entry or a one-time usage text file entry. The server side storage is most important because any timestamp generating code will create a new timestamp per GET request (here, a synonym for refresh), thus ! solving your problem. ip addresses can be changed and cookies can be deleted (edited or spoofed for that matter). UPDATE auctions SET timer = :generated_timestamp WHERE user_id = :userid execute(array('generated_timestamp' => $ttl, ':userid' => $userid)); example where $ttl = (int) 180; for three minutes. * example does not implement db or text file storage and retrieval. <?php $ttl = (int) 180; $ttl += time(); echo $ttl; ?> <!DOCTYPE HTML> <html> <body> <p id="demo">0h 3m 00s</p> <!--button onclick="countdownTimeStart()">Start Timer</button--> <script> function countdownTimeStart(){ var x = setInterval(function() { let currentTime = new Date().getTime(); let countDownTime = new Date(<?php echo $ttl; ?>*1000).getTime(); let timeElapsed = countDownTime - currentTime; // Time calculations for days, hours, minutes and seconds var hours = Math.floor((timeElapsed % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((timeElapsed % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((timeElapsed % (1000 * 60)) / 1000); // Output the result in an element with id="demo" document.getElementById("demo").innerHTML = hours + "h " + minutes + "m " + seconds + "s "; // If the count down is over, write some text if (timeElapsed < 0) { clearInterval(x); document.getElementById("demo").innerHTML = "EXPIRED"; } }, 1000); } window.onload = function () { countdownTimeStart() }; </script> </body> </html> plus what Barand and Requinix mentioned. Otherwise, Barand or Requinix posted your solution. Best wishes.
  7. Hi devjoe. I have looked at the source code of a a few pages using the provided link. troubleshooting revelations 1a. images glob brace includes jpg/jpeg, png and gif 1b. website source code shows .webp 2a. image source displays a single image with only an alt tag 2b. website source code contains a source set, noscript element 3a. you did not mention wordpress in the post. 3b. you did not mention using a wordpress image plugin. glob to show images in a strictly php coded page is not what i am seeing. php code, wordpress code, wordpress plugin code and javascript code is alot to consider. i am not a wordpress user, so i stop at strictly php coded pages. you should post the entire php source code for a selected page to increase the chances of finding a resolution. code snippet: <h2 class="elementor-heading-title elementor-size-default">You might also like</h2> <div class="elementor-element elementor-element-11c4633 elementor-grid-5 elementor-posts--align-center elementor-grid-tablet-5 elementor-grid-mobile-1 elementor-posts--thumbnail-top elementor-widget elementor-widget-posts" data-id="11c4633" data-element_type="widget" data-settings="{&quot;classic_columns&quot;:&quot;5&quot;,&quot;classic_row_gap&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:40,&quot;sizes&quot;:[]},&quot;classic_columns_tablet&quot;:&quot;5&quot;,&quot;classic_columns_mobile&quot;:&quot;1&quot;,&quot;classic_row_gap_tablet&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:&quot;&quot;,&quot;sizes&quot;:[]},&quot;classic_row_gap_mobile&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:&quot;&quot;,&quot;sizes&quot;:[]}}" data-widget_type="posts.classic"> <div class="elementor-widget-container"> <div class="elementor-posts-container elementor-posts elementor-posts--skin-classic elementor-grid elementor-has-item-ratio"> <article class="elementor-post elementor-grid-item post-3138 post type-post status-publish format-standard has-post-thumbnail hentry category-birds-and-insects"> <a class="elementor-post__thumbnail__link" href="https://spiritualgleam.com/spiritual-meaning-of-hearing-birds-chirping-in-the-morning/" tabindex="-1"> <div class="elementor-post__thumbnail"> <img width="1024" height="453" alt="Awaken to Spirit Bird Morning Chirps Hidden Meanings" nitro-lazy-src="https://cdn-ilbidpb.nitrocdn.com/WsiTcrzDirPICxMMKBGJctmTwfoVBlEb/assets/images/optimized/spiritualgleam.com/wp-content/uploads/2024/07/Awaken-to-Spirit-Bird-Morning-Chirps-Hidden-Meanings-1024x453.webp" class="attachment-large size-large wp-image-3204 lazyloaded" decoding="async" nitro-lazy-empty="" id="OTc1OjMxMA==-1" src="https://cdn-ilbidpb.nitrocdn.com/WsiTcrzDirPICxMMKBGJctmTwfoVBlEb/assets/images/optimized/spiritualgleam.com/wp-content/uploads/2024/07/Awaken-to-Spirit-Bird-Morning-Chirps-Hidden-Meanings-1024x453.webp"> </div> </a>
  8. <!DOCTYPE html> <html> <body> <script> <?php echo 'const array = ["one", "two", "three"];'.PHP_EOL; ?> for (i=0;i<3;i++) { document.write(array[i]); document.write('<br>'); } </script> </body> </html> your logic needs to change. use php to dynamically author JavaScript code or json/ajax to get values from php scripts. Barand explains the why.
  9. if data is static and you are positive that this is the code that you wish to implement, then your logic needs to change from less than two to a more precise identifier. A switch will work better for you and allow you to adjust the code if you add more items to the array (which should not contain curly braces, rather square brackets). <?php $data=["egg","york","pork"]; $total = count($data); for ($i = 0; $i < $total; $i++) { switch ($i) { case 0: echo '<p>SECTION A<br>'; break; case 2: echo '</p>SECTION B<br>'; break; } echo $data[$i] . '<br>'; } $data2 = (array) ['Section A' => (array) ["egg","york"], 'Section B' => (array) ["pork"]]; foreach ($data2 as $section => $array) { echo '<p>' . $section . '<br>'; foreach ($array as $type) { echo $type.'<br>'; } echo '</p>'; } ?> but i recommend that you build your arrays to structure and identify data, then looping will be easy and the resulting code will be cleaner and more logical. vide data2 array and the subsequent code above.
  10. again with these arrays? you'll never learn, eh? I think that array merge will fail you here with these demands and array combine will throw an error due to the key length mismatches. I can only guess that you are trying to preserve the order of array 11, id est, the key 1 not following 0. I also assume that you want the 10 key moved to array 2 1 key. This is really not how one should code arrays. I can only suggest bad coding practices in an attempt to solve your problem but i may not be understanding you correctly. Very vague. I have a way to mix the arrays but it is not professional coding methods by any stretch of the imagination. Yes i'm saying that the following code is bad. Meantime, the final key can be printed to the screen but outside of the loop. Inside of the loop would require an array count and a counter to find the end of the loop. <?php echo <<<RAYS <html> <head> <title></title> <style> div.raybox { display: block; position: static; width: 20em; height: 18em; vertical-align: top; background: #101010; border-radius: 8px; box-sizing: content-box; overflow: hidden; } div.ray { display: inline-block; position: relative; margin: 4px; padding: 4px; width: 9em; height: 94%; vertical-align: top; background: #000000; color: rgba(240, 240, 240, 0.6); box-sizing: content-box; } </style> </head> <body> RAYS; $aRay = (array) [0 => (array) [0 => "a", 1 => "b", 2 => "c", 3 => "d", 4 => "e", 5 => "f", 6 => "g", 7 => "h", 8 => "i", 9=> "j"], 1 => (array) [0 => "a", 1 => ""]]; $bRay = (array) [0 => "1.1.51", 2 => "1.1.51.2", 3 => "1.1.51.3", 4 => "1.1.51.4", 5 => "1.1.51.5", 6 => "1.1.51.6", 7 => "1.1.51.7", 8 => "1.1.51.8", 9 => "1.1.51.9", 1 => "1.1.51.10", 10 => "1.1.52"]; echo '<div class="raybox">'; echo '<div class="ray">aRay:<br>'; foreach ($aRay as $key => $array) { foreach ($array as $index => $value) { echo '[' . $key . '][' . $index . '] => ' . $value . '<br>'; } } echo '</div>'; echo '<div class="ray">bRay:<br>'; foreach ($bRay as $index => $value) { echo '[' . $index . '] => ' . $value . '<br>'; } echo '</div>'; echo '</div>'; $aRay[1][1] = array_pop($bRay); $stingRay = array (); array_push($stingRay, $bRay); array_push($stingRay, $aRay[0]); array_push($stingRay, $aRay[1]); //echo '<br>'; //print_r($stingRay); //echo '<br>'; //foreach ($stingRay as $key1 => $array) { // foreach ($array as $key2 => $value) { // echo $value . '<br>'; // } //} echo '<br>'; foreach ($stingRay[0] as $key => $value) { echo $value . ': '; echo $stingRay[1][$key] . '<br>'; } echo $stingRay[2][1] . ': ' . $stingRay[2][0]; echo <<<RAYS </body> </html> RAYS; ?> the output is what you are seeking, i think. Otherwise, i would say build a new array with array 11 values as keys in the new array. Then add array 2 values (letters) as values for the new array keys. Then add the last key value pair to the new array. Then you could loop over one array printing keys and values to obtain your objective. I'm ashamed to post this awful code but that is how twisted this concept is becoming. Really try to recode your project correctly and these problems disappear.
  11. yes, i know what you mean and it is a complicated network. I decided to scan neighbors while building a grid array so that i know which connections can be made. This data will be useful in path determinations, especially with a second array holding broken connections awaiting validation. But your code is splendid and works around the problem differently. I will try to get my code done soon. The weekend is coming. Woohoo 🙂
  12. have you looked at the code provided by Elvium? I am aware of the definition of scalable but the individual disconnected tiles in his code are breaking like table cells in Firefox 1. My suggestion is to place the rectangles in a single svg, which is what you have done in your grid code. However, i also recommend creating only two possible doors: bottom and right. Your code is very nice, as usual. Great job. I do not care for the database storage but it is well implemented. You are a master coder. I'm still using my free time to finish my grid but my son is back in school now. I have a little less time in the day. Also, today i had some time but i was leaving my flat and i stumbled across an old man with his pants pulled down and saw a pee puddle on the floor. I was pretty mad. Minus details, he said he was in my building to visit the attorney upstairs. I said, in German language, "German is not my native language and i can read the sign on the front door that the attorney's office is closed". I added "Das ist nicht in Ordnung." What a crappy day. Who enters a building and urinates on the floor? The bad part about the story is that a different attorney was contacted by Police (instead of Police coming when i called them to come). The attorney seemed strangely nonchalant about the matter. I exploded and threw some expletives her way and warned her against continuing to talk in my direction. Needless to say, my free time is much less today. What is wrong with people nowadays? Anyway, I am storing intelligence about the grid in arrays, which can be used in JavaScript if it is to be a game (neighbors, borders, corner tiles, median tiles, distance calculations, etc). Elvium should appreciate your code. Nice work!
  13. Hi Elvium, I've been busy lately. My Son starts school again and i'm back to sleeping 5-6 hours per day during the week. Anyway, I have finally completed a center finding algorithm and it is working well. I decided to focus on the svg. Now i have never studied svg, so i have alot to learn about designing images using svg code. I think that your concept of doors is problematic when you handle them as top left bottom and right stubs that are connected with each svg output to the browser. Multiple svg images is also problematic because if one shrinks the browser window then the tiles are no longer connected. I've been wanting to create a single svg with only bottom and right doors. I've finished the code days ago but i've been working on implementing it with a php loop. Calculating the coordinates is not too difficult. However, i made an svg smiley instead of text and that was difficult to calculate. I have spent the last two days of free time building it and calculating it's position. The following code is simply html with the single svg method as an example of what mean with top bottom left and right causing problems. I do not see that the 'doors' are being used in any way other than perception. So why not switch to bottom and right, which will be easier to enable and disable in code. single svg <html> <head> <title></title> </head> <body> <svg width="270" height="180" xmlns="http://www.w3.org/2000/svg"> <rect width="80" height="80" x="0" y="10" rx="10" ry="10" fill="#333" /> <rect width="10" height="20" x="80" y="42" rx="0" ry="0" fill="#444" stroke="#333" stroke-width="4" /> <rect width="80" height="80" x="90" y="10" rx="10" ry="10" fill="#333" /> <rect width="10" height="20" x="170" y="42" rx="0" ry="0" fill="#444" stroke="#333" stroke-width="4" /> <rect width="80" height="80" x="180" y="10" rx="10" ry="10" fill="#333" /> <rect width="20" height="10" x="30" y="90" rx="0" ry="0" fill="#444" stroke="#333" stroke-width="4" /> <rect width="10" height="20" x="80" y="130" rx="0" ry="0" fill="#444" stroke="#333" stroke-width="4" /> <rect width="80" height="80" x="0" y="100" rx="10" ry="10" fill="#333" /> <rect width="20" height="10" x="120" y="90" rx="0" ry="0" fill="#444" stroke="#333" stroke-width="4" /> <rect width="10" height="20" x="170" y="130" rx="0" ry="0" fill="#444" stroke="#333" stroke-width="4" /> <rect width="80" height="80" x="90" y="100" rx="10" ry="10" fill="#333" /> <rect width="20" height="10" x="210" y="90" rx="0" ry="0" fill="#444" stroke="#333" stroke-width="4" /> <rect width="80" height="80" x="180" y="100" rx="10" ry="10" fill="#333" /> </svg> </body> </html> again, i have programmed his single svg into php because coordinates and dimensions need to be dynamically calculated.
  14. I would not design a site in such a manner. I would recognize the errors in my ways and fix them. 'been there, done that' is a common expression that applies here. But because you asked: <?php $p_id='1.1.51|||1.1.51.2|||1.1.51.3|||1.1.51.4|||1.1.51.5|||1.1.51.6|||1.1.51.7|||1.1.51.8|||1.1.51.9|||1.1.52|||1.1.52.2'; $Q_Id = explode('|||', $p_id); $m = count($Q_Id); $theme = 'b|||c|||d|||e|||f|||g|||h|||i|||j|||k'; $sub = explode(',', $theme); $sub = explode('|||', $sub[0]); $sub2[] = 'a'; $sub = array_merge($sub2, $sub); $n = count($sub) - 1; //print_r($Q_Id); echo '<br>'; //print_r($sub); echo '<br>'; $j = 0; $k = substr($Q_Id[0], 0, 6); for ($i = 0; $i < $m; $i++) { $index = substr($Q_Id[$i], 0, 6); if ($index !== $k) { $j = 0; $k = substr($Q_Id[$i], 0, 6); echo '----- looky here ' . $k . '<br>'; } echo $Q_Id[$i] . ': ' . $sub[$j] . '<br>'; $j++; } ?> I do not understand why you have these ids in a variable. You should store them in an array by an index system so that you know when to start back at the letter a. However, the English alphabet runs out of letters at 26 so do you plan on having a solution for that too? Do you see how such code leads us down a dark spiraling vertex of madness? a black hole. Even light cannot escape this madness. Change your code as soon as possible. Meantime, good luck with all of that and goodnight. I am in a different timezone and it's almost bedtime. edit: to avoid more questions, $k has been set to the value of array key 0.
  15. what kind of train wreck code is that? holy and moly and mother of godsmack. so with the limited splatter that you have provided along with empty array values (id est, value ||| value, ), we can only do so much to help you out. <?php $p_id='1.1.51|||1.1.51.2|||1.1.51.3|||1.1.51.4|||1.1.51.5|||1.1.51.6|||1.1.51.7|||1.1.51.8|||1.1.51.9|||1.1.52|||1.1.52.2'; $Q_Id = explode('|||', $p_id); $m = count($Q_Id); $theme = 'b|||c|||d|||e|||f|||g|||h|||i|||j|||k'; $sub = explode(',', $theme); $sub = explode('|||', $sub[0]); $sub2[] = 'a'; $sub = array_merge($sub2, $sub); $n = count($sub) - 1; //print_r($Q_Id); echo '<br>'; //print_r($sub); echo '<br>'; $j = 0; for ($i = 0; $i < $m; $i++) { if ($Q_Id[$i] === '1.1.52') { $j = 0; } echo $Q_Id[$i] . ': ' . $sub[$j] . '<br>'; $j++; } ?> you really must stop using count in a loop. For the love of PHP just make a variable to hold the count. Also, i need glasses because my eyes are getting bad with age but i still can't read your code because of the lack of spaces. Add dome spaces to make it more legible. Your code is like a messy room. Yakety Yak! Take out the papers and the trash ...
  16. let us clarify: tourney is your table name, correct? $groupno = '$group1', $linkno='$link1' = you cannot update a variable with a variable. you are supposed to be updating a column with new data. you are supposed to select a db column by name, which is to be updated with the variable referenced to by the placeholder. could you show us a bit more details about your database tables?
  17. switching to pdo is a wise decision but you forgot to switch your query code as well ($sql) $pdo = new pdo("mysql:host=$DB_HOST;dbname=$DB_NAME;charset=$DB_ENCODING",$DB_USER,$DB_PASS,$options); $sql = 'UPDATE tourney SET groupno = :group, linkno = :link WHERE id=1'; $conn = $pdo->prepare($sql); $conn->execute(array(':group' => $group1, ':link' => $link1)); groupno = :group groupno needs to be the name of the column in the database which is to be updated likewise for linkno. :group is a named placeholder for the $group1 variable (protects against sql injection attacks). likewise for linkno. report back.
  18. Hi Elvium, so now you think that I'm stupid. LOL. I've done that but my point is that you have a predictable method of disabling 'doors'. When i set the variable to false, the grid reverts to a full grid after a certain amount of clicks on top of predictability (which simply moves left-to-right in many sequences, thus defying randomness.) see my attached image of the false setting and the full grid. (cityblocks1 .jpg) The mathematical algorithms mentioned early can help solve your problems. We do not have a true grid here and it is not weighted with vertices, so many algorithms will not function well. However, it is a cross between a city block map with streets (doors) and a maze. Which is why the manhattan distance (taxi cab) and A* algorithms will work to help with the maze like obstacles of your dead-ends. You don't have to think of anything new, just convert algorithms to php and output data that fits your code (a bit more tricky). I only have so much time per day to work on my grid code. Today i started calculating a central axis and center tiles . I've also added corner tiles- vide cityblocks2.jpg attachment. I'm preparing to integrate A* algorithm but i want to read a bit more about maze generating algorithms for a better trapping/obstacle layout. I'm not a math guru so it am a bit slow. Anyway, i'm just trying to help you succeed in the best possible way. Predictability is not good when we are talking randomness. rand is not a truly random algorithm, which leaves us with mathematical methods.
  19. are you having trouble setting up a databse, accessing the database and hashing a password? let's play squeakyToys and build a basic process for you to follow: after you make a database with a table and columns in your database software and insert the appropriate data in the columns: $dbHost = (string) '127.0.0.1'; //127.0.0.1 == localhost $dbName = (string) ''; //your database name $dbUser = (string) ''; //your database software user name $dbPass = (string) ''; //your database software password $dbAttr = array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC); $dbConnect = new PDO("mysql:host=$dbHost; dbname=$dbName; charset=utf8mb4", $dbUser, $dbPass, $dbAttr); $dbQuery = 'SELECT user_id, user_pass FROM user_table WHERE user_name = :post_username'; $dbPuppy = $dbConnect->prepare($dbQuery); $dbPuppy->execute(array(':post_username' => $username)); //$_POST['username'] $squeakyToy = $dbPuppy->fetch(); //$squeakyToy['user_id']; //$squeakyToy['user_pass']; //$squeakyToy is a variable that holds the data from the SELECTED database column. here user_id and user_pass //the most common variable names = $field, $row, $result //verify that $_POST['password'] hash matches database user_pass hash for the SELECTed user_name if (password_verify($post_password, $squeakyToy['user_pass']) === true) { //if match is true then the user is now logged in } hash your new password, id est, stop using your now public domain password of 'fredpeabody', and store that hash in your database user_table. example code to show how it works (which does not belong on your publicly accessible website😞 <?php $formPass = "joDunn02024"; $showHash = password_hash($formPass, PASSWORD_BCRYPT); echo $showHash; ?> then you will store the output from $showHash in the user_pass column associated with your username. And don't use fred, peabody, body or pea in your new password, in any lettercase. Even with a full stop interjection (fred.peabody) And all users of your site require a unique user name and a password. Stop sharing your password with people. You're supposed to be the site admin for cryin' out loud. And what is wrong with you? LOL. hopefully, you don't write your banking pin number on your forehead so that you don't forget it. Even backwards. Joke: Another error is using Ubuntu over Mint or OpenSuse. Try one of those distros, then your script will work again 🙂 Honestly, you must at least allow php to process the form on the server side where client users cannot see the processing code. only use javascript as minimal client-side form validation before submitting (such as checking on submit for empty fields, maximum/minimum character violations etc.)
  20. Hi Elvium, The new code script works better than your original script in the original post (no broken paths and no 'walking in circles') but the code often produces the same results for several page loads (not very random). I reloaded the page 5 times and the grid didn't change. You could calculate borders and neighbors very easily and use a function to walk around the grid in search of problems and code solutions to any problems. I have detected borders and neighbors since my last post and even added diagonal neighbors in case the grid would be changed to allow diagonal movements. I've added a function to return opposite directions (north returns south). I've also added a Manhattan distance function and it works well. I wonder what you are building: a game, a path finding exercise or something else? ultimately classes would be better for this project. Imagine calling new grid(), new trap(), new monster() etc. Not necessary in development mode, of course, but a better idea in production. Anyway, if you are happy with your new code, then i suppose that this thread is closed. Otherwise, let us know if you need further assistance. I am going to keep working on my own grid code because i find my grid handling code useful in many ways. Plus, i am intrigued by the mathematics behind path finding. Very fascinating.
  21. I'm trying to avoid rudeness but this post does not belong in a PHP coding thread, since it is clearly a third party reinventing the wheel css implementation problem. The third party css implementation is called Tailwind. I have no interest in reading about Tailwind or the other thing that you mentioned. But have you tried troubleshooting? like change object-contain to object-none or object-fill to see what happens. <img id="modal_image_{{ $comment->id }}" src="" class="w-full h-full object-none" /> empty source tag is interesting. Are you using Javascript to set the source? I'm old school: src="image.ext" and be done with it. tailwindcss.com/docs/object-fit "Use the object-contain utility to resize an element's content to stay contained within its container. Use the object-fill utility to stretch an element's content to fit its container. Use the object-none utility to display an element's content at its original size ignoring the container size." <img class="object-none h-48 w-96 ..."> opinion: css and overlays/modals are not so difficult to warrant a third party re-invent the wheel implementation. example using JavaScript which only requires an on-click event to work. Just pass a menu option integer. function OverlayMenusYay(cardinalOpen) { encodeURIComponent(cardinalOpen); switch (cardinalOpen) { case 1: x.style.display = "block"; x.style.width = "100%"; x.style.height = "100%"; x.style.opacity = "0.4"; break; case 2: y.style.display = "block"; y.style.width = "100%"; y.style.height = "100%"; y.style.opacity = "0.4"; break; } return; } function OverlayMenusNay(cardinalClose) { encodeURIComponent(cardinalClose); switch (cardinalClose) { case 1: x.style.display = "none"; x.style.width = "0%"; x.style.height = "0%"; x.style.opacity = "1"; break; case 2: y.style.display = "none"; y.style.width = "0%"; y.style.height = "0%"; y.style.opacity = "1"; break; } return; } style.opacity to make the background less visible. You can even use CSS3 to create tool tips on hover of the close button x.
  22. users of WordPress and LiteSpeed Cache plugin should be aware of a privilege escalation vulnerability. https://www.bleepingcomputer.com/news/security/litespeed-cache-bug-exposes-millions-of-wordpress-sites-to-takeover-attacks/ recommendation: Update LiteSpeed Cache to version 6.4 or later. Best Wishes, John
      • 1
      • Thanks
  23. so you haven't replied in weeks . I assume based upon your post that you just want to remove the loading bar and display successfully loaded message, yes? <html> <head> <title>5 sec div</title> <style> @keyframes loading { from { opacity: 1; } to { opacity: 1; visibility: hidden; } } @keyframes loaded { from {opacity: 0;} to {opacity: 0;} } .loadingbar { max-width: 100px; border: solid 1px #c0c0c0; } .loading { animation: 5s linear loading; opacity: 0; } .loaded { animation: 5s linear loaded; } .load { position: absolute; top: 0 px; left: 0 px; padding: 8 px; } </style> </head> <body> <div class="load loading loadingbar">Loading ...</div> <div class="load loaded">Successfully Loaded</div> </body> </html>
  24. I did some research last night and i stumbled across grid path algorithms in connection with grid games, which could help you determine a path. Mathematicians have created these algorithms so there is no need for us to re-invent the wheel. http://qiao.github.io/PathFinding.js/visual/ so you must decide if you want to use a path algorithm or if you want to use the tile numbers (re-invent the wheel) to calculate with basic arithmetic (neighbors would require more calculation to avoid misplacing traps and blocking a valid path). i've set up the grid with random start and goal nodes which can be passed to an algorithm (which requires adding this code to the grid build and display code) <?php // Grid settings $maxColumns = (int) 3; $maxRows = (int) 4; if ($maxColumns < 3 || $maxColumns > 10 || $maxRows < 3 || $maxRows > 10) { //screen width must be a factor print 'Please change your mapsize'; exit; } // Images (Icons) $iconMonster = '&#129430;'; // Shows a dinosaur $iconTreasure = '&#127873;'; // Shows a gift $monsters = ceil($maxRows * $maxColumns * 0.15); $treasures = floor($maxRows * $maxColumns * 0.25); $svgSize = 100; $fontSize = $svgSize * 2; // Build the full grid with all information $grid = array(); $displayGridArray = (int) 1; $paths = array(); $trapSize = ceil(($maxColumns * $maxRows) / $maxRows - 1); $availableTiles = $maxColumns * $maxRows - ($trapSize + 2); //create random start and goal nodes $nodes = array(); $nodes['start']['icon'] = '&#128578'; $nodes['start']['row'] = mt_rand(1, $maxRows); $nodes['start']['column'] = mt_rand(1, $maxColumns); $nodes['goal']['icon'] = '&#128274'; $nodes['goal']['row'] = mt_rand(1, $maxRows); $nodes['goal']['column'] = mt_rand(1, $maxColumns); while ($nodes['goal']['column'] === $nodes['start']['column']) { $nodes['goal']['column'] = mt_rand(1, $maxColumns); } //build and display the grid $tileCounter = 0; for ($i = 1; $i <= $maxRows; $i++) { for ($j = 1; $j <= $maxColumns; $j++) { $tileCounter++; $grid[$i][$j]['tile'] = $tileCounter; $grid[$i][$j]['exits'] = null; $image = '<svg width="'.$svgSize.'px" height="'.$svgSize.'px" fill="#333" xmlns="http://www.w3.org/2000/svg">'.PHP_EOL; $image .= '<title>tile: '.$grid[$i][$j]['tile'].'&#xA;row: '.$i.'&#xA;column: '.$j.'</title><rect width="80%" height="80%" x="10%" y="10%" rx="5%" ry="5%" />'.PHP_EOL; // Center square if ($i === $nodes['start']['row'] && $j === $nodes['start']['column']) { $image .= '<text x="50%" y="50% "textLength="100%" font-size="'.$fontSize.'%" dominant-baseline="middle" text-anchor="middle">'.$nodes['start']['icon'].'</text>'.PHP_EOL; } if ($i === $nodes['goal']['row'] && $j === $nodes['goal']['column']) { $image .= '<text x="50%" y="50% "textLength="100%" font-size="'.$fontSize.'%" dominant-baseline="middle" text-anchor="middle">'.$nodes['goal']['icon'].'</text>'.PHP_EOL; } if ($i > 1 && $i <= $maxRows) { /* north,top */ $grid[$i][$j]['exits'] .= 'north'; $image .= '<rect width="20%" height="10%" x="40%" y="0%" />'.PHP_EOL; } if ($j > 1 && $j <= $maxColumns) { /* west,left */ $grid[$i][$j]['exits'] .= (!empty($grid[$i][$j]['exits']) ? ', ' : '') . 'west'; $image .= '<rect width="10%" height="20%" x="0%" y="40%" />'.PHP_EOL; } if ($i < $maxRows) { /* south,bottom */ $grid[$i][$j]['exits'] .= (!empty($grid[$i][$j]['exits']) ? ', ' : '') . 'south'; $image .= '<rect width="20%" height="100%" x="40%" y="90%" />'.PHP_EOL; } if ($j < $maxColumns) { /* east,right */ $grid[$i][$j]['exits'] .= (!empty($grid[$i][$j]['exits']) ? ', ' : '') . 'east'; $image .= '<rect width="10%" height="20%" x="90%" y="40%" />'.PHP_EOL; } $image .= '</svg>'; echo $image; } echo '<br>'.PHP_EOL; } if ($displayGridArray) { echo '<p>'; $k = 1; foreach ($grid as $row => $association) { $l = 1; foreach ($association as $column => $data) { echo 'row ' . $k . ', column ' . $l; foreach ($data as $label => $info) { echo ', ' . $label . ': ' . $info; } echo '<br>'; $l++; } $k++; } echo '</p>'; } echo 'total tiles: ' . $tileCounter . '<br>'; echo 'start node: ' . $nodes['start']['row'] . ':' . $nodes['start']['column'] . ' tile ' . $grid[$nodes['start']['row']][$nodes['start']['column']]['tile'] . '<br>'; echo 'goal node: ' . $nodes['goal']['row'] . ':' . $nodes['goal']['column'] . ' tile ' . $grid[$nodes['goal']['row']][$nodes['goal']['column']]['tile'] . '<br>'; echo 'traps: ' . $trapSize . '<br>'; echo 'available tiles = ' . $availableTiles . ' (minus traps, start and goal nodes)<br>'; ?> now you just have to place the monsters and treasures into columns not belonging to start and goal nodes, calculate a path or possible paths, place traps not interfering with atleast one valid path from start to goal and remove the exits that create the traps.. i also created a variable for displaying the grid array for development purposes. let us know if you have problems finishing the code.
  25. I'm trying to build this program myself in spare time but i out of time for now. I have added the "doors" and documented them in the array. <?php // Grid settings $gridWidth = 3; $gridHeight = 4; $svgSize = 100; // Images (Icons) $iconExit = '&#128274;'; // Shows a lock $iconMonster = '&#129430;'; // Shows a dinosaur $iconStart = '&#128578;'; // Shows a smiley $iconTreasure = '&#127873;'; // Shows a gift // Calculate Monsters $monsters = ceil($gridHeight * $gridWidth * 0.15); // Calculate Treasures $treasures = floor($gridHeight * $gridWidth * 0.25); // Make iconBox and shuffleBox $iconBox = array_merge( array_fill(1, $treasures, $iconTreasure), array(1 => $iconExit), array_fill(1, $monsters, $iconMonster), array(1 => $iconStart) ); $shuffleBox = $iconBox; shuffle($shuffleBox); /* Build the full grid with all information ///////////////////////////////////////////////*/ $grid = array(); for ($i = 1; $i <= $gridHeight; $i++) { for ($j = 1; $j <= $gridWidth; $j++) { $grid[$i][$j]['top'] = $grid[$i][$j]['left'] = $grid[$i][$j]['bottom'] = $grid[$i][$j]['right'] = 0; $image = '<svg width="'.$svgSize.'px" height="'.$svgSize.'px" fill="#333" xmlns="http://www.w3.org/2000/svg">'.PHP_EOL; $image .= '<rect width="80%" height="80%" x="10%" y="10%" rx="5%" ry="5%" />'.PHP_EOL; // Center square if ($i > 1 && $i <= $gridHeight) { /* top */ $grid[$i][$j]['top'] = 1; $image .= ' ' . '<rect width="20%" height="10%" x="40%" y="0%" />'.PHP_EOL; } if ($j > 1 && $j <= $gridWidth) { /* left */ $grid[$i][$j]['left'] = 1; $image .= ' ' . '<rect width="10%" height="20%" x="0%" y="40%" />'.PHP_EOL; } if ($i < $gridHeight) { /* bottom */ $grid[$i][$j]['bottom'] = 1; $image .= ' ' . '<rect width="20%" height="100%" x="40%" y="90%" />'.PHP_EOL; } if ($j < $gridWidth) { /* right */ $grid[$i][$j]['right'] = 1; $image .= ' ' . '<rect width="10%" height="20%" x="90%" y="40%" />'.PHP_EOL; } $image .= '</svg>'; echo $image; } echo '<br>'; } //echo '<br>'; print_r($grid); //echo '<br><br>'; $k = 1; foreach ($grid as $row => $association) { $l = 1; foreach ($association as $column => $connection) { foreach ($connection as $door => $status) { echo 'row ' . $k . ', column ' . $l . ', ' . $door . ' door: ' . $status . '<br>'; } $l++; } $k++; echo '<br>'; } ?> Now you just need to think of a path algorithm which needs documented coordinates. Once you have a path, that doesn't involve randomly disabling doors which require checking for broken paths, you can then loop over the necessary connections to disable them as well as display the surprise items. I've removed a few unnecessary variables and comments from the code. I'll try to wok on a path algorithm along side of your path algorithm ideas and we'll see if we can solve your problems. Unless, someone else beats us to it...
×
×
  • 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.