Jump to content

TheStudent2023

Members
  • Posts

    136
  • Joined

  • Last visited

Everything posted by TheStudent2023

  1. @kicken Thanks for reminding my ban history.But that was due to so-called cross posting. No thanks to Benanamen. Not for breaking any forum TOS. I know I push my luck everytime I tag and bother you guys but for some reason I see that unless I pester, my threads get no answers for 3+ days unless I bump it up again. Anyway, enough talk. I am going to do now something that I been planning to do. And that is to re-invent the drawer in the design that I will be familiar with so I can easily find things. Re-invent the wheel. Yes, I am going to build my own PARSER instead. simple_html_dom() parser syntax looks much easier than the DomDocument() parser. I guess the latter was built by some programmer who hated the official one. Yes, I know, your eye brows have flown at the top of your forehead and gonna reply back "NO! No! Do not re-invent the wheel". Stick to the standard parsers. But, like I said, I like procrastination and experimenting, fiddling, playing around. It generates work experience for me. Just watch where my upcoming own parser ends up to. You might even like it. While I try building one, I will encounter a lot of obstacles and ask a lot of tech questions and will get a lot of flavoured answers and get recommended to a lot of php functions that I never would have come across had I not tried re-inventing my own parser. SO yes, some Pos+ will come out of it.Not all Neg-. Stay tuned and look forward for my upcoming parser thread. On caniuse.com. What do you use it for ? Different Langs' Syntax checking ?
  2. @barand Oops! Sorry! I just noticed your age in your logo. Usually, people do not disclose their age. So, I will go easy on you. Thought you were probably in your mid 50's. Did not know you were a pensioner! You a few yrs older than my old man/ Anyway, take care!
  3. @barand Other than, I go and download from: https://domains-monitor.com/domainzones/ What is your advice ? How can I get hold of all active domains in the world for free ? have you ever tried it yourself ?
  4. @kicken Mmm. So, how can I run my own dns server to download all domains then if caching is not the answer ? Actually, you are right. The cached dns server will only cache the ones users request for dns resolving. Silly me!
  5. Wise Guys, I got suggested this few days ago: https://github.com/tatsu-lab/stanford_alpaca When I asked people for a ChatGpt alternative that I can use for free unlimited & unrestricted. I was advised to install one on my end instead as third party services not providing any ChatGPT AI alternatives unrestricted in any way. Now,I want your feed-back on that Standford open source AI ChatGpt alternative. have you ever tried it ? or maybe, you tried others ? If so, which ? I have some basic questions. Where do the likes of these alternatives get their datas from that they give you as answers ? Obviously, like Google, they do not go crawling the whole web and caching every page of every website or indexing links of every page on the internet. It's not easy to build these AIs. How come they all sprung up overnight after ChatGPT srung up ? I mean, what ChatGPT first came out, obviously it was something strange & new to everyone. So, when other big brands wanted to replicate, it should have taken them yrs to research & build their AI technology before releasing one. So, how come it took only a few months for them to learn a new science field and become pro in the field and build alternatives overnight ? How ? How ? Or, did they all check the source code of ChatGPT since it is open source ? And, did you ever do a nosey one on the source code ? Which mirror you suggest I download your suggested AI source code from where I won't catch any viruses ? Maybe you reckon that Standford one is better than ChatGPT and I should go and downbload that instead ? Yes or no ? I refused so far, thinking it won't be upto good standard as ChatGPT. BIG QUESTION Now the big question that has been bothering me why i really did not install that Standford one on my own website to be like ChatGPT .... Say I installed that Standford one on my website and criminals, like hackers, etc. ask it criminal questions and it gives CLEVER criminal advice and criminals act upon the given advice. Will I not be convicted ?
  6. @kicken You know of any good BIND alternatives for Windows as I got to run my own dns cache just to download all active domains and their email addresses in the zones. And someone just suggested to me an AI crawler. I might aswell check what all the fuss is about when they add "AI" onto a crawler's name and see if I can beat them to build a better desktop crawler when I start building my own .exe crawler. If you know of any better AI crawlers and simpler freeware ones then let me know too. be they .exe desktop ones or php ones.
  7. Pro Online Businessers & Technicians, My php searchengine finished. But my web crawler is not. Building 2 versions of the crawler for 2 different environments. Basically, on my searchengine, I will add a link for you to submit your website. No big deal. Yes, I know, I know. Since my SE will be unknown, it will be foolish for me to feel over the moon expecting every website to know me and find their way to my website and get submitting their links. Have my index built that way. That is why been busy last few days building the php crawler. With your helpS, ofcourse. Lol! Wisely decided that, my web crawler will not be botting the web the old fashion way, where I point it to a link and it crawls all domestic links and find it's way to other domains. Messy. Best to feed it a map. Hence, going to program the crawler to not wander off to other websites other than the domain I set it to. So, at the beginning, I will manually first set it to one domain's Xml Sitemap. To one url only. Then, it will stay on that domain extracting & crawling all domestic pages. Then, it will move-on to the next domain's Xml Sitemap that is on the list I feed it. And do the same. In likewise fashion. Here, I got a question for you:How can I find the Xml Sitemap links of all websites in existence ? What is your method to find this out ? I have my own method. I will relate to you what it is. You tell me, if it is orthodox or foolish. And, whether you got a more efficient way to crawl the web or not other than what I planning on doing. You see, I had in mind to run my own dns cache. That way, I get hold of all the domains that are active across the world. But dealing with BIND is too technical for me. Linux is not my stuff! So, do you know of any Windows OS freeware/shareware/GPL/ etc. ones instead ? If so, are you willing to teach me how to set it up to achieve my purpose ? If not, then I will have no choice but to buy the domains list from here: https://domains-monitor.com/domainzones/ (Note, no affiliate links. Plus, it's not my website). After I have downloaded all the active domains, I will use the techniques mentioned in the following tutorial links on how to find a website's Sitemap. https://seocrawl.com/en/how-to-find-a-sitemap I will program the php crawler to use those techniques to generate urls (possible Sitemap urls for each Domain). And then will have to program the php crawler to navigate to the urls it generated to see if the generated links are valid or not. I will open a new thread in the php section, to get help how to write php code for a crawler to test whether a url is live or dead (exists or not). It is not that hard for me to build a .exe crawler (desktop software) for Windows. And so, while I am still learning how to build a web version one (.php), I might aswell get the desktop crawler crawl the web and harvest links. Then, when my website is up & running, I can then upload the urls list to my website to build the searchengine Index. Originally, I did not want to build a .exe crawler as I did not want to have my home computer on 24/7. Thought best, I get the php crawler, which'll be installed on my paid hosted vps. But, I got tonnes of internet data saved on my fone sim. Guess how much data ? I buy data in GB every week. Actually, for 2-3yrs been buying 10GB/wk. Sometimes they give another 10GB/wk bonus. It only costs me around $3USD/£2GBP/2.5Euros a wk. In your countries, how much will it cost you to buy 10GB and does your ISP provide you another 100% bonus ? How much MB/GB you use every wk ? Just you personally and not your whole hsehold. On youtube, I actually spend about 4GB/wk out of 10GB/wk. So, if I renew the pack again then my saved data (6GB) gets rolled over. That is how, I managed to save 100GB. But once I forgot to renew and wham! I lost all that 100GB! This happened thrice to me in one year. I think in 2021. So, I lost 300GB that got saved rolling over each week! Been careful lately. For nearly 1.5yrs and have lost no rolled over data. Guess how much I managed to save of these rolled over datas this time ? Let me check my cell fone. One moment ... **1036946.37MB** So, that is approx 1TB. So how much data you managed to get rolled over (unuased data) like this on your mobile phone sim ? few weeks ago, I lost another 50GB approx of bonus data that I did not finish using as they made changes to their plans to finish using the bonuses they gave lately or lose them. Silly sods! Anyway, ave how much is a website in MB/GB/TB ? Let me calc how many websites ave my .exe desktop crawler will be able to spider before I run out of all saved rolled over data. We do have broad band. Household users use that to browse youtube most. Got internet on mobile to check for watsap messages while on road. I planning on stop buying it now and save money. Quit buying the data bundle on sim will immediately result in me losing out on the 1TB data that got rolled over. Hence, planning on burning some ones & zeros to harvest links for my SE index using the desktop crawler. Get it to make use of all the saved data on my mobile sim. Else, been saving for nothing! When that data is finished, then can make use of the php crawler to run on my webhost's side. Good idea ? Yes or no ? Any advice, tips, tricks, unorthodox ventures you would like to suggest ? Thanks for reading my searchengine building history.
  8. @kicken, I got a little help. So, switched to this: echo 'Title: ' .$title = $title_tag[0]->textContent; echo '<br>'; From: echo 'Title: ' .$title = $tag->getAttribute('textContent'); echo '<br>'; Working now. here is the code, I guess it cannot be any shorter, concise & better. <?php $url = "https://www.daniweb.com/programming/web-development/threads/540013/how-to-find-does-not-contain-or-does-contain"; // https://www.php.net/manual/en/function.file-get-contents $html = file_get_contents($url); //https://www.php.net/manual/en/domdocument.construct.php $doc = new DOMDocument(); // https://www.php.net/manual/en/function.libxml-use-internal-errors.php libxml_use_internal_errors(true); // https://www.php.net/manual/en/domdocument.loadhtml.php $doc->loadHTML($html, LIBXML_COMPACT|LIBXML_NOERROR|LIBXML_NOWARNING); // https://www.php.net/manual/en/function.libxml-clear-errors.php libxml_clear_errors(); $title_tag = $doc->getElementsByTagName('title'); if ($title_tag->length>0) { echo 'Title: ' .$title = $title_tag[0]->textContent; echo '<br>'; } die; ?> You see there any lines that should not be there ? Since this part of the code will not be dealing with xml files is the above xml error reporting code necessary ? Maybe, I should add some other error reporting code that deals with failure to extract from regular html pages ? You yourself will put which code and from which link in DomDocument will you copy it from ? The DomDocument doc is too big. If I start reading from top to bottom, I will forget first half of what i read by the time I end the last half. So better to ask some pro, instead to point me in the right section or direction. Then I go and do some digging.
  9. Fellow Programmers, I was given this to extract meta tags: <?php /* $url = " // https://www.php.net/manual/en/function.file-get-contents $html = file_get_contents($url); //https://www.php.net/manual/en/domdocument.construct.php $doc = new DOMDocument(); // https://www.php.net/manual/en/function.libxml-use-internal-errors.php libxml_use_internal_errors(true); // https://www.php.net/manual/en/domdocument.loadhtml.php $doc->loadHTML($html, LIBXML_COMPACT|LIBXML_NOERROR|LIBXML_NOWARNING); // https://www.php.net/manual/en/function.libxml-clear-errors.php libxml_clear_errors(); // https://www.php.net/manual/en/domdocument.getelementsbytagname.php $title_tags = $doc->getElementsByTagName('title'); if ($title_tags->length > 0) { // https://www.php.net/manual/en/class.domnodelist.php foreach ($title_tags as $tag) { // https://www.php.net/manual/en/domnodelist.item.php echo 'Title: ' .$title = $tag->getAttribute('textContent'); echo '<br>'; } } I could have asked for the code to extract the title but I did not as I thought if I learn the above code then I would be able to extract the title too. i overlooked the fact that, the meta tag and the title tag structure are different. The above code works to extract meta tags. And I knew, if I downright copy the code structure then it will fail to extract the title from the title tag. nevertheless, I like fiddling around and so experimented. Look, these failed as expected as I see blank white page: by: text $title_tags = $doc->getElementsByTagName('title'); if ($title_tags->length > 0) { foreach ($title_tags as $tag) { echo 'Title: ' .$title = $tag->getAttribute('text'); echo '<br>'; } } by: textContent $title_tags = $doc->getElementsByTagName('title'); if ($title_tags->length > 0) { foreach ($title_tags as $tag) { echo 'Title: ' .$title = $tag->getAttribute('textContent'); echo '<br>'; } } by: innertext $title_tags = $doc->getElementsByTagName('title'); if ($title_tags->length > 0) { // https://www.php.net/manual/en/class.domnodelist.php foreach ($title_tags as $tag) { // https://www.php.net/manual/en/domnodelist.item.php echo 'Title: ' .$title = $tag->getAttribute('innertext'); echo '<br>'; } } by: outertext $title_tags = $doc->getElementsByTagName('title'); if ($title_tags->length > 0) { // https://www.php.net/manual/en/class.domnodelist.php foreach ($title_tags as $tag) { // https://www.php.net/manual/en/domnodelist.item.php echo 'Title: ' .$title = $tag->getAttribute('outertext'); echo '<br>'; } } by: innerhtml $title_tags = $doc->getElementsByTagName('title'); if ($title_tags->length > 0) { // https://www.php.net/manual/en/class.domnodelist.php foreach ($title_tags as $tag) { // https://www.php.net/manual/en/domnodelist.item.php echo 'Title: ' .$title = $tag->getAttribute('innerhtml'); echo '<br>'; } } by: outerhtml $title_tags = $doc->getElementsByTagName('title'); if ($title_tags->length > 0) { // https://www.php.net/manual/en/class.domnodelist.php foreach ($title_tags as $tag) { // https://www.php.net/manual/en/domnodelist.item.php echo 'Title: ' .$title = $tag->getAttribute('outerhtml'); echo '<br>'; } } All above failed. As this line is not correct: echo 'Title: ' .$title = $tag->getAttribute('textContent'); echo '<br>'; So, how to fix this line ?
  10. Where is DomDocument doc shows how to extract page title ?
  11. No. I am talking about this part, which me failing to find in the doc: .....IBXML_NOENT|LIBXML_COMPACT); libxml_clear_errors(); The error part.
  12. @ginerjm But you keep saying RTFM. And so, I am. But stuck to find something. So care to help me find it ? I can't find this particular line on the DomDocument Parser docs: $doc->loadHTML($message, LIBXML_NOENT|LIBXML_COMPACT); libxml_clear_errors(); The rest of the code, I found in the doc lastnight. https://www.php.net/domdocument And incase you are wondering how I manage to cook up the code, then answer is: I did not. Got it from somewhere.
  13. @ginerjm Lol! It is working now: ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(E_ALL); //Sitemap Protocol: https://www.sitemaps.org/protocol.html // Initiate ability to manipulate the DOM and load that baby up $doc = new DOMDocument(); // Because we are actually manipulating the DOM, DOMDocument will add complete <html><body> tags we need to strip out //$message = str_replace(array('<body>', '</body>'), '', $doc->saveHTML($doc->getElementsByTagName('body')->item(0))); $message = file_get_contents('https://www.daniweb.com/programming/web-development/threads/538868/simplehtmldom-failing#post2288453'); libxml_use_internal_errors(true); $doc->loadHTML($message, LIBXML_NOENT|LIBXML_COMPACT); libxml_clear_errors(); // Fetch all <a> tags $links = $doc->getElementsByTagName('a'); // If <a> tags exist ... if ($links->length > 0) { // For each <a> tag ... foreach ($links AS $link) { $link->setAttribute('class', 'link-style'); } } $message = str_replace(array('<body>', '</body>'), '', $doc->saveHTML($doc->getElementsByTagName('body')->item(0)));
  14. @kicken Tonight, can you teach me how to read simple_html_dom() parser syntax ? I want to extract page title. On this page: https://stackoverflow.com/questions/11385774/how-to-extract-title-and-meta-description-using-php-simple-html-dom-parser I found 4 different programmers showing 4 different ways to code using the simple_html_dom() parser. Look: 1 $meta_title = $html->find("meta[name='title']", 0)->content; 2 $title = $html->find('title',0)->innertext; 3 $title = array_shift($html->find('title'))->innertext; 4 $title = $html->load('title')->simpletext; //<title>**Text from here**</title> Q1. But where did they find these syntaxes in the parser's manual ? I cannot find any of them! Check the mini doc: https://enb.iisd.org/_inc/simple_html_dom/manual/manual.htm#section_find It seems I am missing where they are looking. have to learn to look in the right direction. So, I need your assistance again, I'm afraid. Q2. From your experience, can you rank these 4 codes where best is on top ? ANd let me know why you ranked the way you did. This should teach me to spot best and effective coding practice. Thanks!
  15. @Barand Thanks! I forgot about that tooltip. That it's called title. Infact, I wrote this code few weeks ago .... function item_submission_form_part_one() { ?> <div style='font-family:verdana;font-size:15px;color:black;text-align:center;' name="item_submission_form" id="item_submission_form" align="center" size="50%"> <form style="background-color:white;" method="POST" action="" name="submit_form_p1" id="submit_form_p1"> <fieldset> <legend align="center"><h3 style="color:black;">Link Submission Form - Part 1/3</h3></legend> <label for="product_type">Product Type:</label> <select name="product_type" id="product_type" title="Select product type"> <option value=""></option> <option value="physical_product" <?php if(ISSET($_POST['product_type']) && !EMPTY($_POST['product_type']) && $_POST['product_type']=='physical product'){$product_type = $_POST['product_type']; echo 'selected';}?>> Physical Product</option> <option value="intangible product" <?php if(ISSET($_POST['product_type']) && !EMPTY($_POST['product_type']) && $_POST['product_type']=='intangible product'){$product_type = $_POST['product_type']; echo 'selected';}?>> Intangible Product</option> <option value="service" <?php if(ISSET($_POST['product_type']) && !EMPTY($_POST['product_type']) && $_POST['product_type']=='service'){$product_type = $_POST['product_type']; echo 'selected';}?>> Service</option> </select> <br> Listing Type: <input type="radio" name="listing_type" id="wanted" title="Check listing type" value="wanted" <?php if(ISSET($_POST['listing_type']) && !EMPTY($_POST['listing_type']) && $_POST['listing_type']=='wanted'){$listing_type = $_POST['listing_type']; echo 'checked';}?>> <label for="under_18">Wanted Item:</label> <input type="radio" name="listing_type" id="have" title="Check listing type" value="have" <?php if(ISSET($_POST['listing_type']) && !EMPTY($_POST['listing_type']) && $_POST['listing_type']=='have'){$listing_type = $_POST['listing_type']; echo 'checked';}?>> <label for="over_18">Have Item:</label> <br> <label for="item">Item</label> <input type="text" name="item" id="item" size="50" minlength="2" maxlength="255" title="Input your item" <?php if(ISSET($_POST['item']) && !EMPTY($_POST['item'])){$item = $_POST['item']; echo 'value="'.$item.'"';}else{echo 'placeholder="'.'Item ...'.'"';}?>> <br> <label for="manufacturer">Manufacturer</label> <input type="text" name="manufacturer" id="manufacturer" size="50" minlength="2" maxlength="255" title="Input your item manufacturer" <?php if(ISSET($_POST['manufacturer']) && !EMPTY($_POST['manufacturer'])){$manufacturer = $_POST['manufacturer']; echo 'value="'.$manufacturer.'"';}else{echo 'placeholder="'.'Manufacturer ...'.'"';}?>> <br> <label for="brand">Brand</label> <input type="text" name="brand" id="brand" size="50" minlength="2" maxlength="255" title="Input your item brand" <?php if(ISSET($_POST['brand']) && !EMPTY($_POST['brand'])){$brand = $_POST['brand']; echo 'value="'.$brand.'"';}else{echo 'placeholder="'.'Brand ...'.'"';}?>> <br> <label for="model">Model</label> <input type="text" name="model" id="model" size="50" minlength="2" maxlength="255" title="Input your item model" <?php if(ISSET($_POST['model']) && !EMPTY($_POST['model'])){$model = $_POST['model']; echo 'value="'.$model.'"';}else{echo 'placeholder="'.'Model ...'.'"';}?>> <br> <label for="serial_number">Serial Number</label> <input type="text" name="serial_number" id="serial_number" size="50" minlength="2" maxlength="255" title="Input your item serial_number" <?php if(ISSET($_POST['serial_number']) && !EMPTY($_POST['serial_number'])){$serial_number = $_POST['serial_number']; echo 'value="'.$serial_number.'"';}else{echo 'placeholder="'.'Serial Number ...'.'"';}?>> <br> <label for="year">Year</label> <input type="text" name="year" id="year" size="50" minlength="2" maxlength="255" title="Input your item year" <?php if(ISSET($_POST['year']) && !EMPTY($_POST['year'])){$year = $_POST['year']; echo 'value="'.$year.'"';}else{echo 'placeholder="'.'Year ...'.'"';}?>> <br> <label for="currency">Currency</label> <input type="text" name="currency" id="currency" size="50" minlength="2" maxlength="255" title="Input your item currency" <?php if(ISSET($_POST['currency']) && !EMPTY($_POST['currency'])){$currency = $_POST['currency']; echo 'value="'.$currency.'"';}else{echo 'placeholder="'.'Currency ...'.'"';}?>> <br> <label for="price">Price</label> <input type="text" name="price" id="price" size="50" minlength="2" maxlength="255" title="Input your item price" <?php if(ISSET($_POST['price']) && !EMPTY($_POST['price'])){$price = $_POST['price']; echo 'value="'.$price.'"';}else{echo 'placeholder="'.'Price ...'.'"';}?>> <br> <label for="title">Title</label> <input type="text" name="title" id="title" size="50" minlength="2" maxlength="255" title="Input your product page's title" <?php if(ISSET($_POST['title']) && !EMPTY($_POST['title'])){$title = $_POST['title']; echo 'value="'.$title.'"';}else{echo 'placeholder="'.'product page title'.'"';}?>> <br> </fieldset> <fieldset> <button type="submit" name="submit_button_1" id="submit_button_1" title="Submit Form - Part 1/3">submit - Part 1/3</button> </fieldset> </form> </div> <?php } Anyways, that dom parser is not showing me how to extract meta tags and page titles. The closest I found a match is this: [attribute]Matches elements that have the specified attribute. Under the attribute filters tab. But that is not helpful to extract meta tags and page titles. Do you know where in the parser manual it teaches what I looking for ? https://enb.iisd.org/_inc/simple_html_dom/manual/manual.htm#section_find Or better, if you know, then show me the code snippets. And show me where in the doc you found the code snippet. Must extract using simple_html_dom parser. And can you check my DomDocument code above ? Thanks!
  16. https://enb.iisd.org/_inc/simple_html_dom/manual/manual.htm#section_find // Find all anchors and images with the "title" attribute $ret = $html->find('a[title], img[title]'); I do not understand the comment. What does that code do ? How can an anchor have a "title" attribute ? Show me an example. Same goes for an img with "title" attribute.
  17. // Find all anchors and images with the "title" attribute $ret = $html->find('a[title], img[title]');
  18. @barand Ok. This is how DomDocument to extract meta tags. Before, I look into your suggested link to learn how to extract meta tags using simple_html_dom parser, what do you think of the following code ? <?php $url = " $html = file_get_contents($url); // Initiate ability to manipulate the DOM and load that baby up $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->loadHTML($html, LIBXML_COMPACT|LIBXML_NOERROR|LIBXML_NOWARNING); libxml_clear_errors(); // Fetch all <meta> tags $meta_tags = $doc->getElementsByTagName('meta'); if ($meta_tags->length > 0) { foreach ($meta_tags as $tag) { // e.g. name="robots" and content="noindex" echo '<b>Meta Name: </b>' .$name = $tag->getAttribute('name'); echo '<br>'; echo '<b>Meta Description: </b>' .$content = $tag->getAttribute('content'); echo '<br>'; } } Can this be improved in quality and cut down on quanity (lines of code) ? Do you see any errors in the code ?
  19. @kicken My Crawler will only start it's crawls from Xml Sitemaps. It will crawl all Xml Sitemaps found on any given site, if more than one SiteMap exists. From SIteMaps, it will extract regular hrefs from a tags. Then visit those html pages and extract the meta tags and title tags. That is all for now. And so, I guess I will ignore that final ELSE from your code as I do not wish to get crawler deal with anymore Xml Files that are not SiteMaps.
  20. @kicken No. I meant, I do not like to copy codes exact as is from tutorial sites, manuals, forums and even from you. That would be like me giving you orders and you writing codes for me and I just using your codes to build my websites. I ask you people code samples to learn your ways of coding. Both basic, orthodox. then, I try changing the codes and experiment, fiddle, test, etc. gain experience. Then, whatever version (that I derived from you peoples' or tutorials codes) works best for me, I just stick to it. memorise the lines and write from memory to a template. So, when I ask for code samples or snippets, do not assume I trying to get you to do work for me ffor free to build my websites. Not using anyone indirectly to build my websites. Just using everytone to learn coding. That is all. In past, some members assumed I just trying to get them do my dirty work for free. Hence, I making things clear again in this forum just incase someone gets that paranoid notion again that I asking for code snippets bit by bit and combining them altogether to build my websites and am not really motivated to learn programming. So, when I pester pros for snippets, you now know what will happen to those snippets. They willfirst become part of my experiments. Right now, trying to get snippets out from pros for code to extract meta tags. Not by using default php code. Php function. But by using parsers: DOm Document & smple_html_document.
  21. @kicken Have you ever thought of getting ChatGpt to build you a Crypto Currency, Wallet & Block Chain ? The thought entered my mind a day ago. Everytime I headover to ChatGpt page, the damn server is down. Hence, never tested it. if you know of better alternatives then let me know the links. Might aswell get it to fix my php codes. And build me my own Crypto Currency, Wallet, API & Block Chain.
  22. So no one in this forum, uses Crypto Currency ? I asking for advice because I want to signup to a wallet for BitCoin. But do not want to pay any extra fees other than the BlockChain fee. I could have asked ChatGpt for an answer but the damn server is down everytime I check. Looking for an alternative.
  23. @ignace Thank you very much! I am sure yourhard work code will become handy to me once I get a little bit more adv in php. Right now, I did not understand most of it. I won't bug you now to explain each of your code lines as it's gonna be sun rise here soon and I got sleep in my eyes. >>Also don't do this: SELECT id,domain,word,phrase from $tbl WHERE $col_1 = ? Because now it's easy for a hacker to do something like: ?col_1=1;DELETE FROM users WHERE id&input_1=1 << I got one question now though, I thought with prepared statements there is no way a hacker can inject anything in the SQL. So, how can he do it here ? Is it because to foil sql injection the SQL has to be hard coded or CONSTANT while mine is not ($tbl) ? How come no one ever told me this ? How come big dogs aided me cook-up the following code but they never pointed my flaw out ? Look what I cooked-up lately last week: LATEST UPDATE <?php //TEMPLATE. //FULLY WORKING! //COMPLETE! //mysqli_stmt_store_result(). //mysqli_stmt_free_result(). //$rows_count = mysqli_stmt_num_rows($stmt). //mysqli_stmt_get_result(). //http_build_query(). //Report Error. ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(E_ALL); //Valid $_GET Items. //$tables = array('spidered_web_index','$submitted_web_index','$items_listings','visiting_history','following_history'); $spidered_web_index = array('id','date_and_time','domain','url','title','header','meta_keyword','meta_description','keyword','keyphrase'); $submitted_web_index = array('id','date_and_time','domain','url','title','description','country','keyword','keyphrase'); $items_listings = array('id','date_and_time','item','brand','manufacturer','model','heading','year','description','price','country','keyword','keyphrase'); $visiting_history = array('id','date_and_time','searcher','domain','url','title','header','description','country','meta_keyword','meta_description','keyword','keyphrase'); $following_history = array('id','date_and_time','searcher','follower','domain','url','title','header','description','country','meta_keyword','meta_description','keyword','keyphrase'); $tables = ['spidered_web_index'=> ['id'=>'ID', 'date_and_time'=>'Date & Time', 'domain'=>'Domain', 'domain_point'=>'Domain Point', 'url'=>'Url', 'url'=>'Url Point', 'title'=>'Title', 'title'=>'Title Point', 'heading_1'=>'Heading 1', 'heading_1_point'=>'Heading 1 Point', 'heading_2'=>'Heading 2', 'heading_2_point'=>'Heading 2 Point', 'heading_3'=>'Heading 3', 'heading_3_point'=>'Heading 3 Point', 'heading_4'=>'Heading 4', 'heading_4_point'=>'Heading 4 Point', 'heading_5'=>'Heading 5', 'heading_5_point'=>'Heading 5 Point', 'heading_6'=>'Heading 6', 'heading_6_point'=>'Heading 6 Point', 'keyword_superscript'=>'Keyword Superscript', 'keyword_superscript'=>'Keyword superscript', 'keyword_strong'=>'Keyword Strong', 'keyword_strong'=>'Keyword Strong', 'keyword_emphasised'=>'Keyword Emphasised', 'keyword_emphasised'=>'Keyword Emphasised', 'keyword_bold'=>'Keyword Bold', 'keyword_bold'=>'Keyword Bold', 'keyword_italic'=>'Keyword Italic', 'keyword_italic'=>'Keyword Italic', 'keyword_marked'=>'Keyword Marked', 'keyword_marked'=>'Keyword Marked', 'keyword_inserted'=>'Keyword Inserted', 'keyword_inserted'=>'Keyword Inserted', 'keyword_deleted'=>'Keyword Deleted', 'keyword_deleted'=>'Keyword Deleted', 'keyword_small'=>'Keyword Small', 'keyword_small'=>'Keyword Small', 'keyword_subscript'=>'Keyword Subscript', 'keyword_subscript'=>'Keyword Subscript' ], 'submitted_web_index'=> ['id'=>'ID', 'date_and_time'=>'Date & Time', 'domain'=>'Domain', 'domain_point'=>'Domain Point', 'url'=>'Url', 'url'=>'Url Point', 'title'=>'Title', 'title'=>'Title Point', 'heading_1'=>'Heading 1', 'heading_1_point'=>'Heading 1 Point', 'heading_2'=>'Heading 2', 'heading_2_point'=>'Heading 2 Point', 'heading_3'=>'Heading 3', 'heading_3_point'=>'Heading 3 Point', 'heading_4'=>'Heading 4', 'heading_4_point'=>'Heading 4 Point', 'heading_5'=>'Heading 5', 'heading_5_point'=>'Heading 5 Point', 'heading_6'=>'Heading 6', 'heading_6_point'=>'Heading 6 Point', 'keyword_superscript'=>'Keyword Superscript', 'keyword_superscript'=>'Keyword superscript', 'keyword_strong'=>'Keyword Strong', 'keyword_strong'=>'Keyword Strong', 'keyword_emphasised'=>'Keyword Emphasised', 'keyword_emphasised'=>'Keyword Emphasised', 'keyword_bold'=>'Keyword Bold', 'keyword_bold'=>'Keyword Bold', 'keyword_italic'=>'Keyword Italic', 'keyword_italic'=>'Keyword Italic', 'keyword_marked'=>'Keyword Marked', 'keyword_marked'=>'Keyword Marked', 'keyword_inserted'=>'Keyword Inserted', 'keyword_inserted'=>'Keyword Inserted', 'keyword_deleted'=>'Keyword Deleted', 'keyword_deleted'=>'Keyword Deleted', 'keyword_small'=>'Keyword Small', 'keyword_small'=>'Keyword Small', 'keyword_subscript'=>'Keyword Subscript', 'keyword_subscript'=>'Keyword Subscript' ] , 'links_crawls_drummin' => ['id' => "ID" ,'date_and_time' => "Date and Time" ,'domain' => "Domain" ,'domain_point' => "Domain Point" ,'url' => "URL" ,'url_point' => "Url Point" ,'title' => "Title" ,'title_point' => "Title Point" ,'header' => "Header" ,'header_point' => "Header Point" ,'kw_1' => "Keyword 1" ,'kw_1_point' => "Keyword 1 Point" ,'kw_2' => "Keyword 2" ,'kw_2_point' => "Keyword 2 Point" ,'kw_3' => "Keyword 3" ,'kw_3_point' => "Keyword 3 Point" ,'kw_4' => "Keyword 4" ,'kw_4_point' => "Keyword 4 Point" ,'description' => "Description" ,'description_point' => "Description Point" ], 'links_submits_drummin' => ['id' => "ID" ,'date_and_time' => "Date and Time" ,'domain' => "Domain" ,'domain_point' => "Domain Point" ,'url' => "URL" ,'url_point' => "Url Point" ,'title' => "Title" ,'title_point' => "Title Point" ,'header' => "Header" ,'header_point' => "Header Point" ,'kw_1' => "Keyword 1" ,'kw_1_point' => "Keyword 1 Point" ,'kw_2' => "Keyword 2" ,'kw_2_point' => "Keyword 2 Point" ,'kw_3' => "Keyword 3" ,'kw_3_point' => "Keyword 3 Point" ,'kw_4' => "Keyword 4" ,'kw_4_point' => "Keyword 4 Point" ,'description' => "Description" ,'description_point' => "Description Point" ], ]; //Extract $_GETs. $table = !EMPTY($_POST['tbl'])?$_POST['tbl']:(!EMPTY($_GET['tbl'])?$_GET['tbl']:'spidered_web_index'); $column = !EMPTY($_POST['col'])?$_POST['col']:(!EMPTY($_GET['col'])?$_GET['col']:'id'); $limit = !EMPTY($_POST['lmt'])?$_POST['lmt']:(!EMPTY($_GET['lmt'])?$_GET['lmt']:1); $match = !EMPTY($_POST['mtch'])?$_POST['mtch']:(!EMPTY($_GET['mtch'])?$_GET['mtch']:'fuzzy'); $search = !EMPTY($_POST['srch'])?$_POST['srch']:(!EMPTY($_GET['srch'])?$_GET['srch']:'mobile'); $page = !EMPTY($_GET['pg'])?intval($_GET['pg']):1; $offset = ($page*$limit)-$limit; $headings = array_values($tables[$table]); $columns = array_keys($tables[$table]); echo $columns_count = count($columns); if(!in_array($column,$columns)) { die('Invalid Column!'); } if(!in_array($tables[$table],$tables)) { die('Invalid Table!'); } $search = (!EMPTY($search) && $match==='fuzzy')?str_replace('*','%',$search):$search; $char_types = str_repeat('s',$columns_count); $search_values = array_fill(0,$columns_count,$search); $comparator = ($match==='exact')?'=':'LIKE'; $sql = "SELECT * FROM $table WHERE " .implode(" $comparator ? OR ",$columns) ." $comparator ? "; $sql .= "ORDER BY id DESC LIMIT $limit OFFSET $offset"; //Query DB. mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $conn = mysqli_connect("localhost","root","","buzz"); //mysqli_connect("server","user","password","db"); mysqli_set_charset($conn,'utf8mb4'); if(mysqli_connect_errno()) { printf("Mysqli Connection Error: %s",mysqli_connect_error()); } $stmt = mysqli_stmt_init($conn); if(!mysqli_stmt_prepare($stmt,$sql)) //Fetch Rows based on Row Limit per page. { echo 'Mysqli Error: ' .mysqli_stmt_error($stmt); echo '<br>'; echo 'Mysqli Error No: ' .mysqli_stmt_errno($stmt); } else { mysqli_stmt_bind_param($stmt,$char_types,...$search_values); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); //Necessary to use with mysqli_stmt_num_rows() when SQL query is SELECT. echo '<br><br>';echo '<br><br>';echo '<br><br>';echo '<br><br>'; //Fetch Matching Rows Count. //mysqli_stmt_num_rows() has to come after mysqli_stmt_store_result(). echo 'Total Result: ' .$rows_count = mysqli_stmt_num_rows($stmt); echo '<br><br>'; mysqli_stmt_free_result($stmt); //Is this really necessary ? if(!mysqli_stmt_prepare($stmt,$sql)) //Fetch Rows based on Row Limit per page. { echo 'Mysqli Error: ' .mysqli_stmt_error($stmt); echo '<br>'; echo 'Mysqli Error No: ' .mysqli_stmt_errno($stmt); } else { mysqli_stmt_bind_param($stmt,$char_types,...$search_values); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); mysqli_stmt_free_result($stmt); //Is this really necessary ? while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) { for($i=0;$i<$columns_count;$i++) { echo '<b>'.$headings[$i].': </b>'.$row[$columns[$i]]; echo '<br>'; } } } } mysqli_stmt_close($stmt); mysqli_close($conn); echo 'Total Pages: ' .$total_pages = ceil($rows_count/$limit); echo '<br><br>'; $i = 0; while($i<$total_pages) { $i++; $pagination_section_array = array("tbl"=>"$table","mtch"=>"$match","lmt"=>"$limit","srch"=>"$search","pg"=>intval($i)); $serps_url = $_SERVER['PHP_SELF'].'?'.http_build_query($pagination_section_array,'','&amp;'); //Did convert '&' to '&amp' and so NO need to add htmlspecialchars() when echoing link. if($i==$page) { echo '<a href="' .$serps_url .'">' ."<b>$i</b>" .'</a>'; //No need to add htmlspecialchars(), to convert '&' to '&amp;', when echoing link here. } else { echo '<a href="' .$serps_url .'">' ."$i" .'</a>'; //No need to add htmlspecialchars(), to convert '&' to '&amp;', when echoing link here. } } echo '<br>'; ?> The above is a dynamic pagination script. Unorthodox Pagination script. Flexible Coding Pagination script. On it, can you guess what I am trying to achieve there since I did not write the prepared statements the orthodox way such as the following ? The bold text are the hints: $stmt = mysqli_stmt_init($conn); mysqli_stmt_prepare($stmt,$sql_count); mysqli_stmt_bind_param($stmt,"s",$input); mysqli_stmt_execute($stmt); That LATEST UPDATE code you see above. I wrote it less than a week ago. It was derived from the SIMPLE pagination script you see in my original post you see in this thread. Anyway, I am starting to like you. You are getting in my good books. You are starting to engage in my threads. Good man! I think if I hang onto you just a little longer without frustrating you with tonnes of basic questions and you bear patiently my unorthodox childish programming questions, then I might just learn a few wisdom (gold nuggets) from you! Your latest code has got me interested. Grabbed my attention. Great piece of work! You know what you talking about! After addressing this particular post (reply to you), do you mind checking up above what I asked Mac_gyver and answer on his behalf as he is not responding for a few days now. I need answers to the questions I asked him as a reply to his reply to my op ? Finally, do checkout all my other threads. Trying to build a searchengine. That is the project. Do not mind me tagging you now and then. Respond when you are free. Not gonna expect you to respond immediately. Thanks!
×
×
  • 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.