Jump to content

GamerGun

Members
  • Posts

    151
  • Joined

  • Last visited

About GamerGun

  • Birthday 02/24/1989

Contact Methods

  • MSN
    gamergun@hotmail.com
  • Website URL
    http://www.gamergun.nl/

Profile Information

  • Gender
    Male
  • Location
    Eindhoven, The Netherlands

GamerGun's Achievements

Member

Member (2/5)

0

Reputation

  1. Fixed it. In the first script, which scrapes the data, i had: preg_match_all('=<p>(.*)</p>=siU', $result, $match, PREG_PATTERN_ORDER); $match = $match[1]; foreach($match as $matches){ $second = "<p>$matches</p>"; echo $second; fwrite($fp, $second); } Which i changed to; preg_match_all('=<p>(.*)</p>=siU', $result, $match, PREG_PATTERN_ORDER); $match = $match[1]; foreach($match as $matches){ $second = "<p>$matches</p>\n"; echo $second; fwrite($fp, $second); } (see the \n at $second) Now the text file looks like this; <h2> Hooikoortssituatie gunstig </h2><p><strong>Zeist - 11 juni 2010 - Het is vandaag bewolkt en buiig. Pollen die eventueel in de lucht komen worden er in het algemeen weer uitgespoeld. Na vandaag wordt de situatie een stuk minder gunstig.</strong></p> <p><strong>Vandaag</strong> is het overwegend bewolkt en vanmiddag ontstaan er enkele regen- en onweersbuien. Er komen niet veel pollen in de lucht en de lucht wordt af en toe schoon gespoeld.<br /> <br /> <strong>Morgen</strong> zijn er nog veel wolken en kan er lokaal nog een buitje vallen. Al met al komen er wel meer pollen in de lucht dan vandaag.</p> <p>Daarna is het overwegend droog en komt de zon er goed bij. Het aantal pollen in de lucht neemt toe.</p> <p> </p> <p><strong>Meer informatie vindt u op de </strong><a href="http://www.weeronline.nl/Europa/Hooikoorts-Nederland/135"><strong>hooikoortspagina </strong></a><strong>van WeerOnline.</strong><br /> <br /> <strong><br /> </strong></p> <p><strong><img height="405" width="420" src="http://data.weeronline.nl/html/images/weernieuws/image/grassen.jpg" alt="" /><br /> </strong> </p> <p> </p> Which allows me to delete the last 8 rows, without losing other text. Thanks!
  2. Well, i guess i got it. The output of the script i use is; <h2> Hooikoortssituatie gunstig </h2><p><strong>Zeist - 11 juni 2010 - Het is vandaag bewolkt en buiig. Pollen die eventueel in de lucht komen worden er in het algemeen weer uitgespoeld. Na vandaag wordt de situatie een stuk minder gunstig.</strong></p><p><strong>Vandaag</strong> is het overwegend bewolkt en vanmiddag ontstaan er enkele regen- en onweersbuien. Er komen niet veel pollen in de lucht en de lucht wordt af en toe schoon gespoeld.<br /> <br /> <strong>Morgen</strong> zijn er nog veel wolken en kan er lokaal nog een buitje vallen. Al met al komen er wel meer pollen in de lucht dan vandaag.</p><p>Daarna is het overwegend droog en komt de zon er goed bij. Het aantal pollen in de lucht neemt toe.</p><p> </p><p><strong>Meer informatie vindt u op de </strong><a href="http://www.weeronline.nl/Europa/Hooikoorts-Nederland/135"><strong>hooikoortspagina </strong></a><strong>van WeerOnline.</strong><br /> <br /> <strong><br /> </strong></p><p><strong><img height="405" width="420" src="http://data.weeronline.nl/html/images/weernieuws/image/grassen.jpg" alt="" /><br /> </strong> </p><p> </p> As you can see, the last 'blank lines' are because of the <p> constructions. So i have the str_replace these first, then i can go ahead with the rest... Also, the line with the link to their website is on the same line as the one i want to keep.
  3. It's missing another row. See; http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations I get the information from there. What i just don't want is (last 3 lines); The blank line The line with the image The line with the link to their site ("Meer informatie vindt u op de hooikoortspagina van WeerOnline.") But now with -2 its also deleting the line after "Morgen..." I'm clueless... (please note that this page changes every day, sometimes there is no blank line, sometimes there is, but the image and link to their site is always there).
  4. Strange, there seems to be an empty row at the end of the file. but it only removes the last 'filled' row, even when i use -3... Any idea?
  5. Hello y'all. I like to remove the last 2 lines from a flat file via PHP: <?php // Read the file into an array $lines = file('/home/mqxfaokl/domains/informatiehooikoorts.nl/public_html/hooikoortsverwachting.txt'); // Pop the last item from the array array_pop($lines); // Join the array back into a string $file = join('', $lines); // Write the string back into the file $file_handle = fopen('/home/mqxfaokl/domains/informatiehooikoorts.nl/public_html/hooikoortsverwachting.txt', 'w'); fputs($file_handle, $file); fclose($file_handle); ?> This removes only the last line. Now i thought this would work; <?php // Read the file into an array $lines = file('/home/mqxfaokl/domains/informatiehooikoorts.nl/public_html/hooikoortsverwachting.txt'); // Pop the last item from the array array_slice($lines, 0, -2); // Join the array back into a string $file = join('', $lines); // Write the string back into the file $file_handle = fopen('/home/mqxfaokl/domains/informatiehooikoorts.nl/public_html/hooikoortsverwachting.txt', 'w'); fputs($file_handle, $file); fclose($file_handle); ?> But it doesn't do a thing? Any idea? Thanks!
  6. Got it! <?php $userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"; $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_URL,'http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations'); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER,1); curl_setopt($curl_handle, CURLOPT_USERAGENT, $userAgent); curl_setopt($curl_handle, CURLOPT_FAILONERROR, true); curl_setopt($curl_handle, CURLOPT_AUTOREFERER, true); curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10); $result = curl_exec($curl_handle); curl_close($curl_handle); preg_match_all('=<h1[^>]*>(.*)</h1>=siU', $result, $match, PREG_PATTERN_ORDER); $match = $match[1]; foreach($match as $matches){ echo "<h2>$matches</h2>"; } preg_match_all('%<p>(.*?)</p>%', $result, $match, PREG_PATTERN_ORDER); $match = $match[1]; foreach($match as $matches){ echo "$matches<br /><br />"; } ?> Thanks!
  7. Thanks, it works so far <?php $userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"; $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_URL,'http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations'); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER,1); curl_setopt($curl_handle, CURLOPT_USERAGENT, $userAgent); curl_setopt($curl_handle, CURLOPT_FAILONERROR, true); curl_setopt($curl_handle, CURLOPT_AUTOREFERER, true); curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10); $result = curl_exec($curl_handle); curl_close($curl_handle); preg_match_all('%<p>(.*?)</p>%', $result, $match, PREG_PATTERN_ORDER); $match = $match[1]; foreach($match as $matches){ echo "$matches<br /><br />"; } ?> I just don't get it to work with the h1 tags, when i replace <p> with <h1> and </p> with </h1> it outputs nothing... Any idea? Thx
  8. Dear, Currently i'm having the following code: <?php $userAgent = ‘Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)’; $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,'http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); curl_setopt($curl_handle,CURLOPT_USERAGENT, $userAgent); curl_setopt($curl_handle, CURLOPT_FAILONERROR, true); curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl_handle, CURLOPT_AUTOREFERER, true); curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10); $buffer = curl_exec($curl_handle); curl_close($curl_handle); print $buffer; ?> This does show the content from http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations Though, the only part i want is from: <h1> In het westen redelijk veel pollen </h1> 'till <p class="author"> Auteur: Marie-Jette Wierbos - 17 mei 2010 - 02:00 </p> This, and everything in between, does change every day. So basically i want the text (no images and such) from the <h1> 'till the </p> Any idea how? Thanks!
  9. And the contents of foo and bar are for example the addresses and subject or am i seeing it wrong?
  10. There might be a time that i want to mail something different or so, which i then can do via the browser. Anyhow, thanks for your reply. Now is see why it's not working. But i just don't get the $argv thing, what should go in there? http://mardix.wordpress.com/2009/03/07/how-to-pass-variables-to-php-cli-shell-script/
  11. Haha well i do have that; 0 10 * * 6 I assume this is correct for 00:10 saturday?
  12. Hey all, I have created the following script: mailer.php <?php include '../header.php'; ?> <div id="content"> <div id="contentleft"> <h2>Nieuwsbrieven versturen</h2> <?php $inum1 = rand(0,255); $inum2 = rand(0,255); $inum3 = rand(0,255); $inum4 = rand(0,255); $ip = $inum1.'.'.$inum2.'.'.$inum3.'.'.$inum4; $sql = mysql_query('SELECT * FROM `nieuwsbrief` WHERE `bevestigd` = 1') or die(mysql_error()); $num_rows = mysql_num_rows($sql)or die(mysql_error()); while ($row = mysql_fetch_array($sql)) { $slp = $_POST["speed"]; sleep($slp); $beste = $row["naam"]; $to = $row["email"]; $week = date('W'); $subject = "Nieuwsbrief www.watmijoverkwam.nl week $week"; $sender = "admin@watmijoverkwam.nl"; $headers .= "From: $sender\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=utf-8\r\n"; $headers .= "Reply-To: $sender"; $dezepagina = "<a href=\"http://watmijoverkwam.nl/afmelden.html\">afmeldpagina</a>."; $url = "<a href=\"http://watmijoverkwam.nl/\">http://watmijoverkwam.nl/</a>"; $msg = $_POST["message"]; $var1 = "Beste $beste,<br /><br />Hierbij sturen we je de nieuwste verhalen van afgelopen week.<br /><br />"; $var2 = $msg; $var3 = "Je ontvangt deze nieuwsbrief omdat je bent aangemeld op $url.<br />Wil je deze nieuwsbrief niet meer ontvangen?<br />Meldt je dan af op de $dezepagina"; $var4 = "<br /><br />Met vriendelijke groeten,<br />$url"; $fullmsg = $var1.$var2.$var3.$var4; mail($to,$subject,$fullmsg,$headers); echo "Nieuwsbrief verzonden aan: " . $row["naam"] . " - " . $row["email"] . "<br />\n"; } ?> <br /> </div><!-- Closing contentleft --> <?php include '../menu.php'; ?> <?php include '../footer.php'; ?> </div> </body> </html> send.php <?php $corkey1 = "X"; $corkey2 = "Y"; $control1 = $_GET["key1"]; $control2 = $_GET["key2"]; if ( $control1 == $corkey1 && $control2 == $corkey2 ) { echo ""; } else { echo "Ga weg!"; die; } ?> <?php include '../header.php'; ?> <div id="content"> <div id="contentleft"> <h2>Nieuwsbrief opstellen</h2> <form id="mform" name="mform" method="post" action="mailer.php"> Speed<br> <select name="speed"> <option value="1">Insane</option> <option value="4">Fast</option> <option value="8" selected="selected">Normal</option> <option value="12">Slow</option> </select> <br> Message:<br> <textarea name="message" rows="25" cols="75" wrap="off"> <?php $result = mysql_query("SELECT * FROM berichten WHERE TO_DAYS(NOW())-TO_DAYS(datum) <=7 ORDER BY id DESC") or die(mysql_error()); function neat_trim($str, $n, $delim='...') { $len = strlen($str); if ($len > $n) { preg_match('/(.{' . $n . '}.*?)\b/', $str, $matches); return rtrim($matches[1]) . $delim; } else { return $str; } } while($row = mysql_fetch_array($result)){ $id = $row['id']; $message = $row['bericht']; $onderwerp = $row['onderwerp']; $titel = $row['titel']; $titel2 = eregi_replace(' ', '-', $titel); $titel2 = strtolower($titel2); $titellink = "<a href=\"http://watmijoverkwam.nl/$titel2-$id.html\">$titel</a>"; $verderlezen = "<a href=\"http://watmijoverkwam.nl/$titel2-$id.html\">Lees verder</a>"; echo $titellink; echo " ("; echo $onderwerp; echo ")"; echo "\n<br />"; echo neat_trim($message, 120); echo "\n<br />"; echo $verderlezen; echo "\n\n<br /><br />"; } ?> </textarea> <br> <input type="submit" name="start sending" value="Start Sending" > </form> <br /> </div><!-- Closing contentleft --> <?php include '../menu.php'; ?> <?php include '../footer.php'; ?> </div> <script language="JavaScript">document.mform.submit();</script> </body> </html> Send.php contains a form and such, from which the mail will send (default values from the form, the rest will get via the mailer.php). As you can see i did set 2 keys in send.php, which need to be filled in (like send.php?key1=X&key2=Y) in order for the script to work. This works all fine. As for the cronjob i enter: /usr/local/bin/php -q /home/mqxfaokl/domains/watmijoverkwam.nl/public_html/mail/send.php?key1=X&key2=Y Though, via the cronjob it does not work. Perhaps because the script needs some time to process the e-mails. How can i make sure that the cronjob does not 'kill' the script right along but waits 'till it is done loading the mailer.php file? Thanks in advance.
  13. The whole script. Seems like the preg_split is not working or something.
  14. You mean PREG_SPLIT_DELIM_CAPTURE right? So i changed this line; $word_array = preg_split('/[\s?:;,.]+/', $keywords, -1, PREG_SPLIT_NO_EMPTY); Into this; $word_array = preg_split('/[\s?:;,.]+/', $keywords, -1, PREG_SPLIT_DELIM_CAPTURE); But the output is still the same? 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.