예제 #1
0
 public function responseMsg()
 {
     //get post data, May be due to the different environments
     $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
     //extract post data
     if (!empty($postStr)) {
         $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
         $fromUsername = $postObj->FromUserName;
         $toUsername = $postObj->ToUserName;
         $keyword = trim($postObj->Content);
         $time = time();
         $textTpl = "<xml>\r\n\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\r\n\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\r\n\t\t\t\t\t<CreateTime>%s</CreateTime>\r\n\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\r\n\t\t\t\t\t<Content><![CDATA[%s]]></Content>\r\n\t\t\t\t\t<FuncFlag>0</FuncFlag>\r\n\t\t\t\t\t</xml>";
         if (!empty($keyword)) {
             $msgType = "text";
             $contentStr = $keyword;
             // 判断是否首次关注
             if ($keyword == "Hello2BizUser") {
                 $contentStr = "欢迎关注天气宝宝,请输入你要查询的城市!";
             } else {
                 $contentStr = getWeather($keyword);
             }
             $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
             echo $resultStr;
         } else {
             echo "Input something...";
         }
     } else {
         echo "";
         exit;
     }
 }
예제 #2
0
function demo_end()
{
    $result = new Result();
    $zip = $result->getValue();
    $weather_info = getWeather($zip);
    $city = array_pop($weather_info);
    $tropo = new Tropo();
    $tropo->say("The current weather for {$city} is...");
    foreach ($weather_info as $info) {
        $tropo->say("{$info}.");
    }
    $tropo->say("Thank you for calling. Goodbye.");
    $tropo->hangup();
    return $tropo->RenderJson();
}
function formatWeatherResponse(&$tropo, $zip)
{
    // Get weather information for the zip code the caller entered.
    $weather_info = getWeather($zip);
    $city = array_pop($weather_info);
    // Begin telling the user the weather for the city their zip code is in.
    $tropo->say("The current weather for {$city} is...");
    // Iterate over an array of weather information.
    foreach ($weather_info as $info) {
        $tropo->say("{$info}.");
    }
    // Say thank you (never hurts to be polite) and end the session.
    $tropo->say("Thank you for using Tropo!");
    $tropo->hangup();
}
예제 #4
0
 private function tq()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $ipInfo = json_decode(ipToPlace($ip), true);
     $data = json_decode(getWeather($ipInfo['retData']['city']), true);
     if (!$data['errNum']) {
         $t = $data['retData']['city'] . '今天' . $data['retData']['today']['week'] . '当前气温' . $data['retData']['today']['curTemp'] . $data['retData']['today']['fengxiang'] . $data['retData']['today']['fengli'] . '最低气温' . $data['retData']['today']['lowtemp'] . '最高气温' . $data['retData']['today']['hightemp'] . $data['retData']['today']['type'] . '。';
         foreach ($data['retData']['forecast'] as $v) {
             $t .= $v['week'] . $v['fengxiang'] . $v['fengli'] . '最低气温' . $v['lowtemp'] . '最高气温' . $v['hightemp'] . $v['type'] . ';';
         }
     } else {
         $t = '没有查询到天气信息';
     }
     return $t;
 }
예제 #5
0
 function getWiki()
 {
     if (!isset($_SESSION['wiki']['city'])) {
         //获取城市--通过ip
         $city = getCurrentCity();
         if (!$city) {
             $_SESSION['wiki']['city'] = $city = '深圳';
             $_SESSION['wiki']['cityId'] = 77;
         }
         $data['city'] = $city;
         $weather = getWeather($city);
         $data['weather'] = $_SESSION['wiki']['weather'];
         echo json_encode($data);
         exit;
     } else {
         $data['city'] = $_SESSION['wiki']['city'];
         if (!isset($_SESSION['wiki']['weather'])) {
             getWeather($data['city']);
         }
         $data['weather'] = $_SESSION['wiki']['weather'];
         echo json_encode($data);
         exit;
     }
 }
예제 #6
0
require_once __DIR__ . '/classes/connexion.php';
require_once __DIR__ . '/classes/checkAPI.php';
require_once __DIR__ . '/classes/Settings.php';
require_once __DIR__ . '/classes/Alarm.php';
require_once __DIR__ . '/classes/Mode.php';
require_once __DIR__ . '/classes/VigilanceMeteo.php';
require_once __DIR__ . '/classes/Weather.php';
$page_level = 1;
$settings = new Settings();
$vigilance = new VigilanceMeteo();
if (isset($_REQUEST['api']) && checkAPI($_REQUEST['api'], $page_level)) {
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            $alarm = $settings->getSettings('Alarm', 'status');
            http_response_code(202);
            echo json_encode(array('alarm' => $alarm, 'weather' => getWeather(), 'rooms' => getRooms(), 'mode' => (new Mode())->getMode()));
            break;
        case 'PUT':
            echo json_encode(update($_REQUEST));
            break;
    }
} else {
    if ($argc > 1) {
        switch ($argv[1]) {
            case 'weather':
                setWeather();
                break;
        }
    } else {
        http_response_code(403);
    }
예제 #7
0
파일: weather.php 프로젝트: Jim-MK/strom
<?php

$weather = getWeather();
if ($_GET['callback']) {
    $cb = $_GET['callback'];
    echo "{$cb}&&{$cb}({$weather})";
} else {
    echo $weather;
}
function getCity()
{
    $ip = getIp();
    $uri = "http://api.map.baidu.com/location/ip?ak=A20cb515b0fa284cb99c36956c06e737&ip={$ip}&coor=bd09ll";
    $str = file_get_contents($uri);
    $cityArr = json_decode($str);
    if ($cityArr->{'status'} == 0) {
        return $cityArr->{'content'}->{'address_detail'}->{'city'};
    } else {
        return '';
    }
}
function getWeather()
{
    $city = getCity();
    $uri = "http://api.map.baidu.com/telematics/v3/weather?location={$city}&output=json&ak=A20cb515b0fa284cb99c36956c06e737";
    $str = file_get_contents($uri);
    return $str;
}
function getIp()
{
    static $realip;
예제 #8
0
            $line = str_replace("℃", "", $line);
            $line = str_replace("mm", "", $line);
            preg_match($regex, $line, $matches);
            $arr_data[$day]['avg'] = $matches[1];
            // 평균기온
            $arr_data[$day]['high'] = $matches[2];
            // 최고기온
            $arr_data[$day]['low'] = $matches[3];
            // 최저기온
            $arr_data[$day]['cloud'] = $matches[4];
            // 평균운량
            $arr_data[$day]['rain'] = trim(str_replace("-", '0', $matches[5]));
            // 일강수량
            $day++;
        }
    }
    return $arr_data;
}
// main routine
// ====================
$yy = $_REQUEST['yy'];
// 년도
$mm = $_REQUEST['mm'];
// 월
$stn = $_REQUEST['stn'];
// 지역
$yy = $yy == '' ? date("Y") : $yy;
$mm = $mm == '' ? date('m') : $mm;
$stn = $stn == '' ? 108 : $stn;
$arr_data = getWeather($yy, $mm, $stn);
echo json_encode($arr_data);
예제 #9
0
<?php

require 'feixin.php';
$data = getWeather();
$str = matchSTR($data);
sendFetion($str);
function matchSTR($data)
{
    preg_match('/".*"/', $data, $matches);
    $str = trim(iconv('gbk', 'UTF-8', $matches[0]), '"');
    return $str;
}
function getWeather()
{
    $ch = curl_init();
    $url = "http://mat1.qq.com/weather/inc/minisite2_252.js";
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $ret = curl_exec($ch);
    curl_close($ch);
    return $ret;
}
예제 #10
0
파일: weather.php 프로젝트: nrooney/rcs_oma
/*
 * RCS Web App Weather PHP Proxy
 * author: Natasha Rooney
 * date: 25/10/12
 *
 * LOTS OF WORK NEEDED HERE - GET WORKS BUT NOT PUT OR POST
 */
$path = $_SERVER['DOCUMENT_ROOT'];
$rest = $path . "/rcs/php/rest.php";
include_once $rest;
$APIKEY = '1a4b57ad8c140130120411';
if (isset($_POST['action']) && !empty($_POST['action'])) {
    //$authuser = $_POST['authuser'];
    $location = $_POST['location'];
    getWeather($location);
}
/*
 * getWeather
 * http://free.worldweatheronline.com/feed/weather.ashx?q=London&format=json&num_of_days=2&key=1a4b57ad8c140130120411
 */
function getWeather($location)
{
    global $SERVER_URL, $APIKEY;
    $request = new RestRequest("http://free.worldweatheronline.com/feed/weather.ashx?q=" . $location . "&format=json&num_of_days=2&key=" . $APIKEY, 'GET', "");
    //echo "http://free.worldweatheronline.com/feed/weather.ashx?q=".$location."&format=json&num_of_days=2&key=".$APIKEY;
    $request->execute();
    $info = $request->getResponseInfo();
    if ($info['http_code'] == 200) {
        echo $request->getResponseBody();
    } else {
예제 #11
0
(at your option) any later version.
"Podes reiseplanlegger" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with "Podes reiseplanlegger".  If not, see <http://www.gnu.org/licenses/>.
Source code available from: 
http://github.com/pode/reiseplanlegger/
*/
include_once '../config.php';
if (!$config['modules']['weather']['enabled']) {
    exit;
}
//henter været basert på lengde-, breddegrad og tidssone
$weather = getWeather($_GET['lat'], $_GET['lon'], $_GET['timeZone']);
//skriver ut været
echo "\t\t\tVind: " . $weather['windSpeed'] . "<br />\n";
echo "\t\t\tTemperatur: " . $weather['temperature'] . " &deg; C<br /><br />\n";
echo "\t\t</td>\n";
echo "\t\t<td>\n";
echo "\t\t\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"" . $weather['symbol'] . "\" alt=\"v&aelig;rsymbol\"/><br />\n";
echo "\t\t</td>\n";
echo "\t\t</tr>\n";
echo "\t</table>\n";
//skriver ut lenke til yr slik lisensen krever
echo "V&aelig;rvarsel fra <a href=\"http://www.yr.no/\">yr.no</a>, levert av Meteorologisk institutt og NRK<br /><br />\n";
/*
funksjon som henter returnerer vindinfo, tempinfo og værsymbol
for gitt lengde- og breddegrad ($lat og $lon). $timeZone brukes
for å bestemme om det er natt eller dag
예제 #12
0
    $gctr++;
    if ($response = geoPlanet($place)) {
        $correctResp = true;
        $xmlObj = simplexml_load_string($response);
        $arrXml = objectsIntoArray($xmlObj);
        if ($arrXml['place']['name'] == $arrXml['place']['locality1'] || $arrXml['place']['name'] == $arrXml['place']['locality2']) {
            $woeid = true;
        } else {
            $place = $arrXml['place']['locality1'] != "" ? $arrXml['place']['locality1'] : $arrXml['place']['locality2'];
        }
    } else {
        $correctResp = false;
    }
} while (!$woeid && $gctr <= 2 && $correctResp);
if ($woeid) {
    if (($weather = getWeather($arrXml['place']['woeid'])) !== false) {
        $weather_return = $arrXml['place']['name'] . "\n";
        $weather_return .= "Temperature: " . $weather['temperature'] . " C \n";
        $weather_return .= "Weather: " . $weather['text'] . "\n";
        $weather_return .= "Humidity: " . $weather['humidity'] . " % \n";
        $weather_return .= "Pressure: " . $weather['pressure'] . " bar \n";
        $weather_return .= "Tomorrow's Forecast\n";
        $weather_return .= "Temperature: " . $weather['forecast'][1]['low'] . ' C - ' . $weather['forecast'][1]['high'] . " C \n";
        $weather_return .= "Weather: " . $weather['forecast'][1]['text'] . " \n";
    } else {
        $weather_return = '';
    }
}
/** GET WOEID * */
function geoPlanet($place)
{
예제 #13
0
function setCurrentCity($cityId)
{
    $data = M("Region")->where("type=2")->find($cityId);
    if (!$data) {
        return false;
    }
    $_SESSION['wiki']['city'] = $data['name'];
    getWeather($data['name']);
    $_SESSION['wiki']['cityId'] = $data['id'];
    return true;
}
예제 #14
0
    /*
    	print "now: $now\n";
    	print "nowPretty: $nowPretty\n";
    	print "apparent: ". $weatherCSV['apparent'] ."\n";
    	print "relative: ". $weatherCSV['relative'] ."\n";
    	print "barometer: ". $weatherCSV['barometer'] ."\n";
    	print "sustained: ". $weatherCSV['sustained'] ."\n";
    	print "gust: ". $weatherCSV['gust'] ."\n";
    	print "wind: ". $weatherCSV['wind'] ."\n";
    	print "weather-conditions: ". $weatherCSV['weather-conditions'] ."\n";
    */
    $stringCSV = "";
    $stringCSV .= "{$now}";
    $stringCSV .= "," . $nowPretty;
    $stringCSV .= "," . $weatherCSV['apparent'];
    $stringCSV .= "," . $weatherCSV['relative'];
    $stringCSV .= "," . $weatherCSV['barometer'];
    $stringCSV .= "," . $weatherCSV['sustained'];
    $stringCSV .= "," . $weatherCSV['gust'];
    $stringCSV .= "," . $weatherCSV['wind'];
    $stringCSV .= "," . $weatherCSV['weather-conditions'];
    print $stringCSV . "\n";
}
foreach ($places as $place => $location) {
    $lat = $location['lat'];
    $lon = $location['lon'];
    getWeather($place, $lat, $lon);
    buildArray($weatherXML);
    makeCSV($weatherCSV);
    print "===========================\n";
}
예제 #15
0
파일: bot.php 프로젝트: NevDK91/vk-chat-bot
<?php

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/lib/lib.php';
require __DIR__ . '/lib/vk.api.php';
require __DIR__ . '/config/config.php';
$response = $v->api('messages.get', ['count' => 10]);
$messages = $response['items'];
foreach ($messages as $message) {
    if (!$message['read_state']) {
        if (preg_match('/бот/ui', $message['body'])) {
            if (preg_match('/(погода|погоду).(.*)/ui', $message['body'], $city)) {
                $city = explode(' ', $city[0]);
                $weater = getWeather($city[2]);
                if ($weater) {
                    $messageText = empty($city[2]) ? "Я не понял запрос. Напиши так: покажи погоду в киеве" : getWeather($city[2]);
                } else {
                    $messageText = 'Не могу найти погоду в ' . $city[2];
                }
                sendMessage($message, $messageText, $v);
            }
            if (preg_match('/факт/ui', $message['body'])) {
                $messageText = getRandomFact();
                sendMessage($message, $messageText, $v);
            }
            if (preg_match('/команды|как с тобой разговаривать|помощь/ui', $message['body'])) {
                $messageText = "\n\t\t\t\t\t\tЯ тебе не бесдушная скотина, поэтому называй мое имя, когда пишешь мне.\n\n\t\t\t\t\t\t1. Показать команды: бот, покажи команды\n\n\t\t\t\t\t\t2. Показать погоду: Покажи погоду в city_name. Пример: бот, покажи погоду в киеве\n\n\t\t\t\t\t\t3. Интересный факт: бот, покажи интересный факт";
                sendMessage($message, $messageText, $v);
            }
            if (preg_match('/фото/', $message['body'])) {
                $attachments = $v->upload_photo(false, ['images/deer.jpg']);
예제 #16
0
파일: world.php 프로젝트: hrosalgado/TFG
/**
 * Action see
 * It returns the positions and the elements that an element can see, if these positions have an element
 *
 * @param Element Element
 *
 * @return array Positions and elements
 */
function see($element)
{
    $see = array();
    $seeWrite = '';
    $position = $element->getPosition();
    switch (get_class($element)) {
        case 'Rabbit':
            if (getWeather() == 'foggy' || !getStatusDay()) {
                $viewRange = 0;
            } else {
                $viewRange = $_POST['seeRabbit'];
            }
            break;
        case 'Wolf':
            if (getWeather() == 'foggy' || !getStatusDay()) {
                $viewRange = 0;
            } else {
                $viewRange = $_POST['seeWolf'];
            }
            break;
    }
    $rowStart = $position[0] - $viewRange;
    $colStart = $position[1] - $viewRange;
    $rowEnd = $position[0] + $viewRange;
    $colEnd = $position[1] + $viewRange;
    while ($rowStart <= $rowEnd) {
        while ($colStart <= $colEnd) {
            if (!isLocked($rowStart, $colStart)) {
                if (!($rowStart == $position[0] && $colStart == $position[1]) && get_class(getWorld()[$rowStart][$colStart]) != 'Ground') {
                    array_push($see, array(get_class(getWorld()[$rowStart][$colStart]), array($rowStart, $rowEnd)));
                    $seeWrite .= $rowStart . '.' . $colStart . get_class(getWorld()[$rowStart][$colStart]) . ',';
                }
            }
            $colStart++;
        }
        $colStart = $position[1] - $viewRange;
        $rowStart++;
    }
    writeFileCSV('Log', array(getTime(), '', get_class($element), $element->getId(), '[ ' . $element->getPosition()[0] . ' - ' . $element->getPosition()[1] . ' ]', '', 'see', $seeWrite));
    return $see;
}
예제 #17
0
function curweather_network_mod_init(&$fk_app, &$b)
{
    if (!intval(get_pconfig(local_user(), 'curweather', 'curweather_enable'))) {
        return;
    }
    $fk_app->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $fk_app->get_baseurl() . '/addon/curweather/curweather.css' . '" media="all" />' . "\r\n";
    // $rpt value is needed for location
    // $lang will be taken from the browser session to honour user settings
    // TODO $lang does not work if the default settings are used
    //      and not all response strings are translated
    // $units can be set in the settings by the user
    // $appid is configured by the admin in the admin panel
    // those parameters will be used to get: cloud status, temperature, preassure
    // and relative humidity for display, also the relevent area of the map is
    // linked from lat/log of the reply of OWMp
    $rpt = get_pconfig(local_user(), 'curweather', 'curweather_loc');
    //  set the language to the browsers language and use metric units
    $lang = $_SESSION['language'];
    $units = get_pconfig(local_user(), 'curweather', 'curweather_units');
    $appid = get_config('curweather', 'appid');
    $cachetime = intval(get_config('curweather', 'cachetime'));
    if ($units === "") {
        $units = 'metric';
    }
    $ok = true;
    $res = getWeather($rpt, $units, $lang, $appid, $cachetime);
    if ($res === false) {
        $ok = false;
    }
    if ($ok) {
        $t = get_markup_template("widget.tpl", "addon/curweather/");
        $curweather = replace_macros($t, array('$title' => t("Current Weather"), '$icon' => proxy_url('http://openweathermap.org/img/w/' . $res['icon'] . '.png'), '$city' => $res['city'], '$lon' => $res['lon'], '$lat' => $res['lat'], '$description' => $res['descripion'], '$temp' => $res['temperature'], '$relhumidity' => array('caption' => t('Relative Humidity'), 'val' => $res['humidity']), '$pressure' => array('caption' => t('Pressure'), 'val' => $res['pressure']), '$wind' => array('caption' => t('Wind'), 'val' => $res['wind']), '$lastupdate' => t('Last Updated') . ': ' . $res['update'] . 'UTC', '$databy' => t('Data by'), '$showonmap' => t('Show on map')));
    } else {
        $t = get_markup_template('widget-error.tpl', 'addon/curweather/');
        $curweather = replace_macros($t, array('$problem' => t('There was a problem accessing the weather data. But have a look'), '$rpt' => $rpt, '$atOWM' => t('at OpenWeatherMap')));
    }
    $fk_app->page['aside'] = $curweather . $fk_app->page['aside'];
}
예제 #18
0
        }
    }
    // Get current temperature
    $regex = "/<span class='current'>(.*?)°<\\/span>/";
    preg_match($regex, $data, $curr);
    // Get forecast days
    $regex = "/<tr>\n<th class='empty'>(?:.*)<\\/th>\n<th colspan='2' scope='col'>(.*?)<\\/th>\n<th colspan='2' scope='col'>(.*?)<\\/th>\n<th colspan='2' scope='col'>(.*?)<\\/th>/";
    preg_match($regex, $data, $day);
    // Get minimum temperature for forecast days
    $regex = "/<tr>\n<th scope='row'>Minimum<\\/th>\n<td colspan='2'>\n<span class='min'>(.*?)°<\\/span>\n<\\/td>\n<td colspan='2'>\n<span class='min'>(.*?)°<\\/span>\n<\\/td>\n<td colspan='2'>\n<span class='min'>(.*?)°<\\/span>/";
    preg_match($regex, $data, $min);
    // Get maximum temperature for forecast days
    $regex = "/<tr>\n<th scope='row'>Maximum<\\/th>\n<td colspan='2'>\n<span class='max'>(.*?)°<\\/span>\n<\\/td>\n<td colspan='2'>\n<span class='max'>(.*?)°<\\/span>\n<\\/td>\n<td colspan='2'>\n<span class='max'>(.*?)°<\\/span>/";
    preg_match($regex, $data, $max);
    // Get outlook for forecast days
    $regex = "/<th scope=\\'row\\'>Summary<\\/th>\n<td colspan=\\'2\\'>\n<img (?:.*?) title=\"(.*?)\" \\/>\n<\\/td>\n<td colspan=\\'2\\'>\n<img (?:.*?) title=\"(.*?)\" \\/>\n<\\/td>\n<td colspan=\\'2\\'>\n<img (?:.*?) title=\"(.*?)\" \\/>/";
    preg_match($regex, $data, $outlook);
    // Generate html to display on screen
    $res = $loc[1] . " " . $postcode . "<br/>";
    $res .= "Current Temp: " . $curr[1] . " deg Celsius <br/>";
    $res .= "Forecast(Outlook/Temp-min/max):<br/>";
    for ($i = 1; $i <= count($day) - 1; $i++) {
        $res .= $day[$i] . ": " . $outlook[$i] . " / " . $min[$i] . " / " . $max[$i] . "<br/>";
    }
    return $res;
}
echo getWeather($state, $postcode, $mycity, $mystate);
?>
    </body>
</html>
예제 #19
0
     }
     echo json_encode($arr_varosok);
     break;
 case 'ajaxvalasz':
     //lekérjük a városokat az adatbázisból, amelyeknek az adataira kíváncsiak vagyunk
     $arr_varosok = array();
     $q_varosok = $db->query("SELECT varos_id, varos_nev FROM varosok ORDER BY varos_id");
     if ($q_varosok->num_rows > 0) {
         while ($r_varosok = $q_varosok->fetch_assoc()) {
             $arr_varosok[$r_varosok['varos_id']]['varos_neve'] = $r_varosok['varos_nev'];
         }
     }
     if (!empty($arr_varosok)) {
         //minden városra meghívjuk a SOAP függvényt
         foreach ($arr_varosok as $varos_id => $varos_adatok) {
             $arr_getWeather = getWeather($varos_adatok['varos_neve']);
             $arr_varosok[$varos_id]['homerseklet'] = $arr_getWeather['homerseklet'];
             $arr_varosok[$varos_id]['paratartalom'] = $arr_getWeather['paratartalom'];
             $arr_varosok[$varos_id]['legnyomas'] = $arr_getWeather['legnyomas'];
         }
     }
     //beszúrjuk az adatbázisba az új adatokat
     if (!empty($arr_varosok)) {
         foreach ($arr_varosok as $varos_id => $varos_adatok) {
             $q_beszur = $db->prepare("\n                    INSERT INTO idojaras_adatok\n                    (varos_id, homerseklet, paratartalom, legnyomas, idopont)\n                    VALUES (?, ?, ?, ?, ?)\n                ");
             $q_beszur->bind_param("issss", $varos_id, $varos_adatok['homerseklet'], $varos_adatok['paratartalom'], $varos_adatok['legnyomas'], $NOW);
             $q_beszur->execute();
             $q_beszur->close();
         }
     }
     header("Location: ajax.php?action=default_map");
예제 #20
0
global $postObj;
include_once HANDLE_DIR . 'db.class.php';
include_once HANDLE_DIR . 'tools.class.php';
//实例化数据库类并连接数据库
$db = new DB();
$db->open();
//用户消息
$data1 = array('from' => $postObj->FromUserName, 'to' => $postObj->ToUserName, 'content' => trim($postObj->Content), 'time' => $postObj->CreateTime, 'message_id' => $postObj->MsgId);
//消息存入数据库
$db->insert('wx_message_text', $data1);
//获取默认回复
$default_key = 'ANSWER_DEFAULT_' . round(rand(1, 4));
$contentStr = $db->get_field("wx_config", "_key='{$default_key}'", "_value");
if (mb_substr($data1['content'], 0, 2, 'utf-8') == '天气') {
    //天气查询
    $contentStr = getWeather($data1['content'], false);
} else {
    if (mb_substr($data1['content'], 0, 2, 'utf-8') == '快递') {
        //快递查询
        $contentStr = doGetKuaiDi($data1['content']);
    } else {
        if ($db->count('wx_answer', "_key='{$data1['content']}'") > 0) {
            $contentStr = $db->get_field("wx_answer", "_key='{$data1['content']}'", "_value");
        } else {
            //机器人查询
            $str = $data1['content'];
            $sql = "CONCAT(key1,key2,key3)<>'' and INSTR('{$str}',key1) and INSTR('{$str}',key2) and INSTR('{$str}',key3)  \n\t\t\tor (CONCAT(key1,key2,key3)='' and question='{$str}')";
            $answerStrThird = $db->get_field("wx_answer_robot", $sql, "answer");
            if ($answerStrThird) {
                $contentStr = $answerStrThird;
            }
예제 #21
0
파일: test.php 프로젝트: Nightchen0521/cmf
<?php

/*
 * 摘	要: 天气查询工具使用演示
 * 作       者: 刘海艇
 * 修改日期: 2013-06-27
 */
require_once "index.php";
header("content-type:text/html;charset=utf8");
$start_time = microtime(true);
//---------------------------------
print_r(getWeather('上海市'));
//------------------------------------
$end_time = microtime(true);
echo '<br><br>耗时' . round($end_time - $start_time, 3) . '秒';
예제 #22
0
    <div class="HideMe RetrievedLocation" id="TapToContMsg">Tap to continue</div>
    <div class="RetrievedLocation" id="TopMsgContainer">
        <div id="TopMsg">Tap a day to see details</div>
    </div>
    <div id="MainContent">
        <div class='responsive' id='10dayforecast'>
            <div class="row">
            <?php 
$city = $_GET["city"];
$state = $_GET["state"];
if (is_null($city)) {
    $city = $_COOKIE["city"];
    $state = $_COOKIE["state"];
}
if (!is_null($city) and $city != "null") {
    getWeather($city, $state);
}
function getWeather($city, $state)
{
    setcookie("city", $city, strtotime('+365 days'));
    setcookie("state", $state, strtotime('+365 days'));
    $cityParam = str_replace(" ", "%20", $city);
    $jsonUrl = "http://api.wunderground.com/api/dc7c6e717d1e922e/forecast10day/q/{$state}/{$cityParam}.json";
    $json_string = file_get_contents($jsonUrl);
    //Code to generate day overview content
    $parsed_json = json_decode($json_string, TRUE);
    for ($x = 0; $x <= 9; $x++) {
        $iconUrl = $parsed_json['forecast']['simpleforecast']['forecastday'][$x]['icon_url'];
        $iconUrl = str_replace("/k/", "/i/", $iconUrl);
        $dayOfWeek = $parsed_json['forecast']['simpleforecast']['forecastday'][$x]['date']['weekday_short'] . ".";
        $monthAndDay = $parsed_json['forecast']['simpleforecast']['forecastday'][$x]['date']['monthname_short'] . ". ";
예제 #23
0
//实例化数据库类并连接数据库
$db = new DB();
$db->open();
//用户消息
$data = array('from' => $postObj->FromUserName, 'to' => $postObj->ToUserName, 'text' => (string) $postObj->Recognition, 'media_id' => $postObj->MediaId, 'time' => $postObj->CreateTime, 'format' => $postObj->Format, 'message_id' => $postObj->MsgId);
//消息存入数据库
$db->insert('wx_message_voice', $data);
//获取默认回复
$default_key = 'ANSWER_DEFAULT_' . round(rand(1, 4));
$contentStr = $db->get_field("wx_config", "_key='{$default_key}'", "_value");
if (empty($data['text'])) {
    $contentStr = '您的消息我已经收到!';
} else {
    if (mb_substr($data['text'], 0, 2, 'utf-8') == '天气') {
        //天气查询
        $contentStr = getWeather($data['text'], false);
    } else {
        if (mb_substr($data['text'], 0, 2, 'utf-8') == '快递') {
            //快递查询
            $contentStr = doGetKuaiDi($data['text']);
        } else {
            if ($db->count('wx_answer', "_key='{$data['text']}'") > 0) {
                $contentStr = $db->get_field("wx_answer", "_key='{$data['text']}'", "_value");
            } else {
                //机器人查询
                $str = $data['text'];
                $sql = "CONCAT(key1,key2,key3)<>'' and INSTR('{$str}',key1) and INSTR('{$str}',key2) and INSTR('{$str}',key3)  \n\t\t\tor (CONCAT(key1,key2,key3)='' and question='{$str}')";
                $answerStrThird = $db->get_field("wx_answer_robot", $sql, "answer");
                if ($answerStrThird) {
                    $contentStr = $answerStrThird;
                }