Weather on your site

Started on the old forum in July 2012 · view the original in the archive · old links redirect here

2 replies · 548 views · started 14 years ago · 1 min read

3 participants
kiss Senior · 294 posts #1
<?php
 if ( isset( $_SERVER["HTTP_ACCEPT_ENCODING"] ) && substr_count( $_SERVER["HTTP_ACCEPT_ENCODING"], "gzip" ) ) ob_start( "ob_gzhandler" ) ;
 else  ob_start() ;
 $query = $_POST["query"] ;
 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" ;
 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n" ;
 echo "<head>\n" ;
 echo "<title>Weather " . ucwords( $query ) . "</title>\n" ;
 echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n" ;
 echo "<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>\n" ;
 echo "<meta name=\"description\" content=\"Describe the page\"/>\n" ;
 echo "<meta name=\"keywords\" content=\"Keywords of page\"/>\n" ;
 //echo "<link rel=\"shortcut icon\" href=\"http://" . $_SERVER["HTTP_HOST"] . "/ico/your_weather.ico\"/>\n" ;
 //echo "<link rel=\"stylesheet\" href=\"http://" . $_SERVER["HTTP_HOST"] . "/css/your_style.css\"/>\n" ;
 echo "</head>\n" ;
 echo "<body>\n" ;
 if ( $query != "" ) {
  echo "<center>\n" ;
  echo ucwords( $query ) . "\n" ;
  echo "</center>\n" ;
  $ch = curl_init() ;
  curl_setopt( $ch, CURLOPT_URL, "http://inbuzunar.mobi/meteo.php" ) ;
  curl_setopt( $ch, CURLOPT_HEADER, 0 ) ;
  curl_setopt( $ch, CURLOPT_FRESH_CONNECT, 1 ) ;
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ) ;
  curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" ) ;
  curl_setopt( $ch, CURLOPT_POST, 1 ) ;
  curl_setopt( $ch, CURLOPT_POSTFIELDS, "query=" . $query ) ;
  $curl = curl_exec( $ch ) ;
  curl_close( $ch ) ;
  preg_match_all( '/<div\sclass=\"nolink\">(.+?)<\/div>/si', $curl, $matches ) ;
  //echo "<pre>\n" ;
  //print_r( $matches[1] ) ;
  //echo "</pre>\n" ;
  $totl = count( $matches[1] ) ;
  for ( $i = 0; $i < $totl; $i++ ) {
   echo "<p>" ;
   echo "" . str_replace( array(
    'Luni',
    'Marti',
    'Miercuri',
    'Joi',
    'Vineri',
    'Sambata',
    'Duminica' ), array(
    'Monday',
    'Tuesday',
    'Wednesday',
    'Thursday',
    'Friday',
    'Saturday',
    'Sunday' ), $matches[1][$i] ) ;
   echo "</p>\n" ;
  }
 }
 echo "<center>\n" ;
 echo "<form action=\"" . htmlentities( $_SERVER["PHP_SELF"] ) . "\" method=\"post\">\n" ;
 echo "<input type=\"text\" name=\"query\" maxlength=\"35\" value=\"City/Village\" onfocus=\"if(this.value=='City/Village')this.value=''\" onblur=\"if(this.value=='City/Village')this.value=''\"/>\n" ;
 echo "<input type=\"submit\" value=\"Search\"/>\n" ;
 echo "</form>\n" ;
 echo "Information is taken from <a href=\"http://inbuzunar.mobi\">InBuzunar.Mobi</a>\n" ;
 echo "</center>\n" ;
 echo "<center>\n" ;
 echo "« <a href=\"http://" . $_SERVER["HTTP_HOST"] . "\">Back</a>\n" ;
 echo "</center>\n" ;
 echo "</body>\n" ;
 echo "</html>\n" ;
 ob_end_flush() ;
?>

www.inbuzunar.mobi -Your mobile portal pocket

Vayne Developer · 106 posts #2

cURL is greedy. fopen can do same magic. and y u no use google weather? 🤨

Nous Ne Dansos Pas, Nous Sommes Le Danse.!

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close