{"id":141,"date":"2009-06-04T21:30:49","date_gmt":"2009-06-04T19:30:49","guid":{"rendered":"http:\/\/blogs.wittwer.fr\/whiler\/?p=141"},"modified":"2023-03-12T15:12:38","modified_gmt":"2023-03-12T14:12:38","slug":"chargement-du-contenu-d-une-page","status":"publish","type":"post","link":"https:\/\/blogs.wittwer.fr\/whiler\/2009\/06\/04\/chargement-du-contenu-d-une-page\/","title":{"rendered":"Chargement du contenu d\u2019une page"},"content":{"rendered":"<p>Aujourd&rsquo;hui, <a href=\"https:\/\/www.stjo.fr\/?page=bio&amp;hl=fr\" target=\"_blank\" rel=\"noopener\">StJo<\/a> m&rsquo;a envoy\u00e9 <a href=\"https:\/\/whiler.drofx.com\/\" target=\"_blank\" rel=\"noopener\">un nouveau lien<\/a>&#8230;<\/p>\n<p>Un site qu&rsquo;il est amen\u00e9 \u00e0 faire \u00e9voluer avec le temps.<\/p>\n<p>Dans le principe actuel, on gagne des points <del>toutes les heures<\/del> tous les jours o\u00f9 on se connecte&#8230;<br \/>\nHum&#8230;  <img src=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-includes\/images\/smilies\/skype\/\/happy.gif\" alt=\"(lol)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/>  il faut automatiser cela&#8230;<\/p>\n<p>J&rsquo;ai un planificateur de t\u00e2ches chez mon h\u00e9bergeur qui peut me permettre de me connecter toutes les heures&#8230; mais celui-ci ne m&rsquo;autorise seulement qu&rsquo;\u00e0 lancer des scripts que j&rsquo;h\u00e9berge, et ne me permet pas d&rsquo;appeler une URL externe&#8230;<\/p>\n<p>Qu&rsquo;\u00e0 cela ne tienne&#8230; codons une mini-page qui va se charger du travail et que je mettrai dans le planificateur&nbsp;:<br \/>\n<!--more--><\/p>\n<div class=\"codecolorer-container php dawn\" style=\"overflow:auto;white-space:nowrap;width:480px;height:300px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/><\/div><\/td><td><div class=\"php codecolorer\"><span class=\"kw2\">&lt;?php<\/span><br \/>\n&nbsp; <span class=\"co1\">\/\/ R\u00e9cup\u00e8re la cha\u00eene situ\u00e9e apr\u00e8s le '?' Par exemple : http:\/\/maPage.php?http:\/\/pageACharger<\/span><br \/>\n&nbsp; <span class=\"re0\">$url<\/span> &nbsp; &nbsp;<span class=\"sy0\">=<\/span> <a href=\"http:\/\/www.php.net\/trim\"><span class=\"kw3\">trim<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"re0\">$_SERVER<\/span><span class=\"br0\">&#91;<\/span><span class=\"st0\">&quot;QUERY_STRING&quot;<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; <span class=\"re0\">$source<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$url<\/span> <span class=\"sy0\">!=<\/span> <span class=\"st0\">&quot;&quot;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$handle<\/span> <span class=\"sy0\">=<\/span> <span class=\"sy0\">@<\/span><a href=\"http:\/\/www.php.net\/fopen\"><span class=\"kw3\">fopen<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"re0\">$url<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;r&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$handle<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ Chargement du fichier<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">while<\/span> <span class=\"br0\">&#40;<\/span><span class=\"sy0\">!<\/span><a href=\"http:\/\/www.php.net\/feof\"><span class=\"kw3\">feof<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"re0\">$handle<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"re0\">$buffer<\/span> <span class=\"sy0\">=<\/span> <a href=\"http:\/\/www.php.net\/fgets\"><span class=\"kw3\">fgets<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"re0\">$handle<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">4096<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"re0\">$source<\/span> <span class=\"sy0\">.=<\/span> <span class=\"re0\">$buffer<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <a href=\"http:\/\/www.php.net\/fclose\"><span class=\"kw3\">fclose<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"re0\">$handle<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">else<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ Le script n'a pas p\u00fb ouvrir le fichier<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"re0\">$source<\/span> <span class=\"sy0\">=<\/span><span class=\"st0\">&quot;Ouverture impossible&amp;amp;hellip;&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; <span class=\"kw1\">else<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/ Cette page a \u00e9t\u00e9 appel\u00e9 sans param\u00e8tre (http:\/\/maPage.php)<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$source<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;URL non sp&amp;amp;eacute;cifi&amp;amp;eacute;e&amp;amp;hellip;&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; <span class=\"co1\">\/\/ Affiche ce qui a \u00e9t\u00e9 charg\u00e9 ou le message d'erreur<\/span><br \/>\n&nbsp; <span class=\"kw1\">echo<\/span> <span class=\"re0\">$source<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"sy1\">?&gt;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Je la publie chez mon h\u00e9bergeur et le tour est jou\u00e9&#8230; plus qu&rsquo;\u00e0 mettre le lien dans le planificateur&nbsp;:<br \/>\n<em><span class=\"MT_violet\">http:\/\/maPage.php<span class=\"MT_yellow\">?<\/span>https:\/\/whiler.drofx.com\/<\/span><\/em><\/p>\n<p>Ben non.. le planificateur, dans mon cas ne permet pas de mettre de \u00ab\u00a0<span class=\"MT_yellow\">:<\/span>\u00a0\u00bb dans le chemin d&rsquo;acc\u00e8s au script&#8230; je ne peux donc pas mettre l&rsquo;url du site en param\u00e8tre&#8230; bon, ben j&rsquo;ai cr\u00e9\u00e9 une autre page avec le chemin en dur&nbsp;:<\/p>\n<div class=\"codecolorer-container php dawn\" style=\"overflow:auto;white-space:nowrap;width:480px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/><\/div><\/td><td><div class=\"php codecolorer\"><span class=\"kw2\">&lt;?php<\/span><br \/>\n&nbsp; <span class=\"co1\">\/\/ Chemin en dur<\/span><br \/>\n&nbsp; <span class=\"re0\">$url<\/span> &nbsp; &nbsp;<span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;https:\/\/whiler.drofx.com\/&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; <span class=\"re0\">$source<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$url<\/span> <span class=\"sy0\">!=<\/span> <span class=\"st0\">&quot;&quot;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"sy0\">...<\/span> <span class=\"sy0\">...<\/span> <span class=\"sy0\">...<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Planification effectu\u00e9e avec succ\u00e8s&#8230;<\/p>\n<div id=\"attachment_16\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a title=\"Planificateur de t\u00e2ches : drofx\" href=\"\/whiler\/wp-content\/uploads\/2009\/10\/drofx_webcron.gif\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16\" class=\"size-medium wp-image-16\" title=\"Cliquer pour agrandir\" src=\"\/whiler\/wp-content\/uploads\/2009\/10\/drofx_webcron-300x148.gif\" alt=\"Planificateur de t\u00e2ches : drofx\" width=\"300\" height=\"148\" srcset=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/uploads\/2009\/10\/drofx_webcron-300x148.gif 300w, https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/uploads\/2009\/10\/drofx_webcron.gif 550w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-16\" class=\"wp-caption-text\">Planificateur de t\u00e2ches : drofx<\/p><\/div>\n<p>Je verrai plus tard si j&rsquo;ai besoin d&rsquo;impl\u00e9menter les cookies ou autres choses du genre&#8230;<\/p>\n<div class=\"thanks_button_div\" \n                  style=\"float: right; margin-right: 10px; margin-top:10px;\"><div id=\"thanksButtonDiv_141_1\" style=\"background-image:url(https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/plugins\/thanks-you-counter-button\/images\/thanks_compact_brown1.png); background-repeat:no-repeat; float: left; display: inline;\"\n                onmouseover=\"javascript:thankYouChangeButtonImage('thanksButtonDiv_141_1', true);\" \n                onmouseout=\"javascript:thankYouChangeButtonImage('thanksButtonDiv_141_1', false);\"\n                onclick=\"javascript:thankYouChangeButtonImage('thanksButtonDiv_141_1', false);\" >\n                <input type=\"button\" onclick=\"thankYouButtonClick(141, 'You left &ldquo;Thanks&rdquo; already for this post')\" value=\"Merci\u00a0 0\"\n                  class=\"thanks_button thanks_compact thanks_brown1\"\n                  style=\"  font-family: Verdana, Arial, Sans-Serif; font-size: 14px; font-weight: normal;; color:#00f;\"\n                  id=\"thanksButton_141_1\" title=\"Click to leave &ldquo;Thanks&rdquo; for this post\"\/>\n             <\/div><div id=\"ajax_loader_141_1\" style=\"display:inline;visibility: hidden;\"><img decoding=\"async\" alt=\"ajax loader\" src=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/plugins\/thanks-you-counter-button\/images\/ajax-loader.gif\" \/><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Aujourd&rsquo;hui, StJo m&rsquo;a envoy\u00e9 un nouveau lien&#8230;<\/p>\n<p>Un site qu&rsquo;il est amen\u00e9 \u00e0 faire \u00e9voluer avec le temps.<\/p>\n<p>Dans le principe actuel, on gagne des points toutes les heures tous les jours o\u00f9 on se connecte&#8230;<br \/>\nHum&#8230;:. il faut automatiser cela&#8230;<\/p>\n<p>J&rsquo;ai&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9,11],"tags":[27,37,38,39,108,40],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-php","category-web","tag-coloration-syntaxique","tag-disciple","tag-drofx","tag-fopen","tag-script","tag-stjo"],"_links":{"self":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":1,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":6427,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts\/141\/revisions\/6427"}],"wp:attachment":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}