web/wp-content/plugins/wptouch/include/class.prowl.php
author hurons@caf4f556-3d62-0410-8435-a86758001935
Mon, 01 Feb 2010 09:51:57 +0000
branchwordpress
changeset 123 561aa6d282f6
permissions -rw-r--r--
pre production version : ****************************** Template evolution : - css ( so much things) - js ( new navigation tools ...) - lib for php ZIp - function.php (for download LDT and other litle function) - page (header, home, footer, single, search, searchform, post ...) ****************************** New plug in : - wp touch - wp explorer - TextCutter - ultimate-google-analytics - nice titles ****************************** Plug in customization : - related-posts-by-category - posts-of-current-category - order-categories - event-calendar - translation wp explorer - exec-php ****************************** Road map for next version : - cleaning php code put template function to new plugin - cleaning Css code - re organize Js code - all new correction ask

<?php

class Prowl
{
   var $apikey;
   var $application;
   
   function Prowl($apikey, $application)
   {
      $this->apikey = $apikey;
      $this->application = $application;
     // $this->verify();
   }
   
   function add($priority, $event, $description)
   {
      $options = array(
         'apikey' => $this->apikey,
         'priority' => $priority,
         'application' => urlencode($this->application),
         'event' => urlencode($event),
         'description' => urlencode($description)
      );
      
      $response = $this->request('https://prowl.weks.net/publicapi/add', $options);
      return $this->getresult($response);
   }
   
   function getresult($response) {
		$response = str_replace("\n", " ", $response);
	
		if(preg_match("/code=\"200\"/i", $response))
			return true;
		else
		{
			preg_match("/<error.*?>(.*?)<\/error>/i", $response, $out);
			return $out[1];
		}
   }
   
   function verify()
   {
      $options = array('apikey' => $this->apikey);
      return $this->getresult( $this->request('https://prowl.weks.net/publicapi/verify', $options) );
   }
   
   function request($file, $options)
   {
      $url = $file;
      
      $first = true;
      foreach ($options as $key => $value) {
         $url .= ($first ? '?' : '&') . $key . '=' . $value;
         $first = false;
      }
      
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_HEADER, false);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_TIMEOUT, 10);
      $response = curl_exec($ch);
      curl_close($ch);

      return $response;
   }
}
?>