00001: <?php
00002: /**
00003: * Security example
00004: * that send notifications to Growl using the new GNTP/1.0 protocol
00005: * with encrypted messages
00006: *
00007: * PHP version 5
00008: *
00009: * @category Networking
00010: * @package Net_Growl
00011: * @author Laurent Laville <pear@laurent-laville.org>
00012: * @author Bertrand Mansion <bmansion@mamasam.com>
00013: * @license http://www.opensource.org/licenses/bsd-license.php BSD
00014: * @version CVS: Release: @package_version@
00015: * @link http://growl.laurent-laville.org/
00016: * @since File available since Release 2.0.0RC1
00017: */
00018:
00019: require_once 'Net/Growl.php';
00020:
00021: // Notification Type definitions
00022: define('GROWL_NOTIFY_STATUS', 'GROWL_NOTIFY_STATUS');
00023:
00024: // define a PHP application that sends notifications to Growl
00025: $appName = 'PHP App Example using GNTP';
00026: $notifications = array(
00027: GROWL_NOTIFY_STATUS => array(
00028: 'display' => 'Status',
00029: ),
00030: );
00031:
00032: $password = 'mamasam';
00033: $options = array(
00034: 'host' => '192.168.1.2',
00035: 'protocol' => 'tcp', 'port' => Net_Growl::GNTP_PORT, 'timeout' => 10,
00036: 'AppIcon' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Help.ico',
00037: 'encryptionAlgorithm' => 'AES',
00038: 'passwordHashAlgorithm' => 'SHA256',
00039: 'debug' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'netgrowl.log'
00040: );
00041:
00042: try {
00043: $growl = Net_Growl::singleton($appName, $notifications, $password, $options);
00044: $growl->register();
00045:
00046: $name = GROWL_NOTIFY_STATUS;
00047: $title = 'Congratulation';
00048: $description = 'Congratulation! You are successfull install PHP/NetGrowl.';
00049: $growl->notify($name, $title, $description);
00050:
00051: $name = GROWL_NOTIFY_STATUS;
00052: $title = 'Welcome in PHP/GNTP world';
00053: $description = "New GNTP protocol support 3 encryption algorithms ! \n"
00054: . "DES, 3DES, AES with 4 hash algorithm \n"
00055: . "MD5, SHA1, SHA256, SHA512.";
00056: $options = array(
00057: 'sticky' => true,
00058: );
00059: $growl->notify($name, $title, $description, $options);
00060:
00061: var_export($growl);
00062:
00063: } catch (Net_Growl_Exception $e) {
00064: echo 'Caught Growl exception: ' . $e->getMessage() . PHP_EOL;
00065: }
00066: ?>