function addToQueue($event)
 {
     if ($event) {
         $properties['owa_event'] = base64_encode(serialize($event));
         //$properties = array_map('urlencode', $properties);
         $properties = owa_lib::implode_assoc('=', '&', $properties);
         //print_r($properties);
         //return;
     } else {
         return;
     }
     $parts = parse_url($this->endpoint);
     $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 30);
     if (!$fp) {
         return false;
     } else {
         $out = "POST " . $parts['path'] . " HTTP/1.1\r\n";
         $out .= "Host: " . $parts['host'] . "\r\n";
         $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
         $out .= "Content-Length: " . strlen($properties) . "\r\n";
         $out .= "Connection: Close\r\n\r\n";
         $out .= $properties;
         owa_coreAPI::debug("out: {$out}");
         fwrite($fp, $out);
         fclose($fp);
         return true;
     }
 }
 function makeParamString($params = array(), $add_state = false, $format = 'query', $namespace = true)
 {
     $all_params = array();
     // merge in state params
     if ($add_state) {
         $all_params = array_merge($all_params, $this->getAllStateParams());
     }
     //merge in params
     $all_params = array_merge($all_params, $params);
     switch ($format) {
         case 'query':
             $get = '';
             $count = count($all_params);
             $i = 0;
             foreach ($all_params as $n => $v) {
                 $get .= owa_coreAPI::getSetting('base', 'ns') . $n . '=' . $v;
                 $i++;
                 if ($i < $count) {
                     $get .= "&";
                 }
             }
             $string = $get;
             break;
         case 'cookie':
             $string = owa_lib::implode_assoc('=>', '|||', $all_params);
             break;
     }
     return $string;
 }
 public static function createCookie($cookie_name, $cookie_value, $expires = 0, $path = '/', $domain = '')
 {
     if ($domain) {
         // sanitizes the domain
         $domain = owa_lib::sanitizeCookieDomain($domain);
     } else {
         $domain = owa_coreAPI::getSetting('base', 'cookie_domain');
     }
     if (is_array($cookie_value)) {
         $cookie_value = owa_lib::implode_assoc('=>', '|||', $cookie_value);
     }
     // add namespace
     $cookie_name = sprintf('%s%s', owa_coreAPI::getSetting('base', 'ns'), $cookie_name);
     // debug
     owa_coreAPI::debug(sprintf('Setting cookie %s with values: %s under domain: %s', $cookie_name, $cookie_value, $domain));
     // set compact privacy header
     header(sprintf('P3P: CP="%s"', owa_coreAPI::getSetting('base', 'p3p_policy')));
     //owa_coreAPI::debug('time: '.$expires);
     setcookie($cookie_name, $cookie_value, $expires, $path, $domain);
     return;
 }
Example #4
0
 function persistState($store)
 {
     //check to see that store exists.
     if (isset($this->stores[$store])) {
         owa_coreAPI::debug('Persisting state store: ' . $store . ' with: ' . print_r($this->stores[$store], true));
         // transform state array into a string using proper format
         if (is_array($this->stores[$store])) {
             switch ($this->stores_meta[$store]['type']) {
                 case 'cookie':
                     // check for old style assoc format
                     if ($this->stores_meta[$store]['format'] === 'assoc') {
                         $cookie_value = owa_lib::implode_assoc('=>', '|||', $this->stores[$store]);
                     } else {
                         $cookie_value = json_encode($this->stores[$store]);
                     }
                     break;
                 default:
             }
         } else {
             $cookie_value = $this->stores[$store];
         }
         // get expiration time
         $time = $this->stores_meta[$store]['expiration'];
         //set cookie
         owa_coreAPI::createCookie($store, $cookie_value, $time, "/", owa_coreAPI::getSetting('base', 'cookie_domain'));
     } else {
         owa_coreAPI::debug("Cannot persist state. No store registered with name {$store}");
     }
 }