/** * Returns latest jaws version * * @access public * @return string Json encoded string */ function JawsVersion() { $jaws_version = ''; $httpRequest = new Jaws_HTTPRequest(); $httpRequest->default_error_level = JAWS_ERROR_NOTICE; $result = $httpRequest->get('http://jaws-project.com/version/0', $data); if (!Jaws_Error::IsError($result) && $result == 200) { if (preg_match('/^\\d+(\\.\\d+)+.*/i', $data)) { $jaws_version = $data; $this->gadget->registry->update('update_last_checking', serialize(array('version' => $jaws_version, 'time' => time()))); } } return $jaws_version; }
/** * Ping search engines to announce sitemap.xml updated * * @access public * @return bool True */ function PingSearchEngines() { $url = urlencode($this->gadget->urlMap('SitemapXML', array(), true)); $searchEngines = array('google' => 'http://www.google.com/webmasters/tools/ping?sitemap={url}', 'bing' => 'http://www.bing.com/ping?sitemap={url}'); $httpRequest = new Jaws_HTTPRequest(); $httpRequest->default_error_level = JAWS_ERROR_NOTICE; foreach ($searchEngines as $engine => $pingURL) { $pingURL = str_replace('{url}', $url, $pingURL); $result = $httpRequest->get($pingURL, $retData); if (!Jaws_Error::IsError($result) && $result != 200) { $GLOBALS['log']->Log(JAWS_ERROR_NOTICE, "Could not ping search engine '{$engine}': {$retData}"); } } return true; }
/** * Returns google map image * * @access public * @return void */ function GetGoogleMapImage() { $gMapParams = jaws()->request->fetch(array('latitude', 'longitude', 'zoom', 'size'), 'get'); $gMapURL = 'http://maps.google.com/maps/api/staticmap?center=' . $gMapParams['latitude'] . ',' . $gMapParams['longitude'] . '&zoom=' . $gMapParams['zoom'] . '&size=' . $gMapParams['size'] . '&maptype=roadmap&markers=color:blue|label:x|' . $gMapParams['latitude'] . ',' . $gMapParams['longitude'] . '&sensor=false'; header("Content-Type: image/png"); header("Pragma: public"); $httpRequest = new Jaws_HTTPRequest(); $result = $httpRequest->get($gMapURL, $data); if (Jaws_Error::IsError($result) || $result != 200) { $data = @file_get_contents('gadgets/Weather/Resources/images/gmap.png'); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); } else { $expires = 60 * 60 * 48; header("Cache-Control: max-age=" . $expires); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); } echo $data; }
/** * Send data to parent site * * @access public * @return boolean */ function SendData() { $processing = $this->gadget->registry->fetch('processing'); $lastUpdate = (int) $this->gadget->registry->fetch('last_update'); $queueMaxTime = (int) $this->gadget->registry->fetch('queue_max_time'); if ($processing == 'true' && $lastUpdate + $queueMaxTime < time()) { return false; } $this->gadget->registry->update('last_update', time()); $this->gadget->registry->update('processing', 'true'); $filters = array(); $filters['sync'] = false; $model = $this->gadget->model->load('SiteActivity'); $activities = $model->GetSiteActivities(); if (Jaws_Error::IsError($activities)) { $this->gadget->registry->update('processing', 'false'); return $activities; } $activityIds = array(); foreach ($activities as $activity) { $activityIds[] = $activity['id']; } // Post activities data to parent site $hostName = $_SERVER['HTTP_HOST']; $hostNameArray = explode('.', $hostName); array_shift($hostNameArray); $parentURL = 'http://' . implode('.', $hostNameArray) . '/index.php/SiteActivity/ReceiveData'; $httpRequest = new Jaws_HTTPRequest(); $data = json_encode(array('domain' => $hostName, 'data' => $activities)); $result = $httpRequest->rawPostData($parentURL, $data, $retData); if (Jaws_Error::IsError($result) || $result != 200) { $this->gadget->registry->update('processing', 'false'); return false; } // update sync status $model->UpdateSiteActivitySync($activityIds, true); // finish procession $this->gadget->registry->update('processing', 'false'); return $retData; }