function wait_for_register_response($event, $args) { global $client, $form; if ($event == 'stanza_cb') { $stanza = $args[0]; if ($stanza->name == 'iq') { $form['type'] = $stanza->attrs['type']; if ($stanza->attrs['type'] == 'result') { echo "registration successful" . PHP_EOL . "shutting down..." . PHP_EOL; $client->send_end_stream(); return "logged_out"; } else { if ($stanza->attrs['type'] == 'error') { $error = $stanza->exists('error'); echo "registration failed with error code: " . $error->attrs['code'] . " and type: " . $error->attrs['type'] . PHP_EOL; echo "error text: " . $error->exists('text')->text . PHP_EOL; echo "shutting down..." . PHP_EOL; $client->send_end_stream(); return "logged_out"; } } } } else { _notice("unhandled event {$event} rcvd"); } }
public function __construct($name, $read_cb = null) { $pipes_folder = JAXL_CWD . '/.jaxl/pipes'; if (!is_dir($pipes_folder)) { mkdir($pipes_folder); } $this->ev = new JAXLEvent(); $this->name = $name; $this->read_cb = $read_cb; $pipe_path = $this->get_pipe_file_path(); if (!file_exists($pipe_path)) { posix_mkfifo($pipe_path, $this->perm); $this->fd = fopen($pipe_path, 'r+'); if (!$this->fd) { _error("unable to open pipe"); } else { _debug("pipe opened using path {$pipe_path}"); _notice("Usage: \$ echo 'Hello World!' > {$pipe_path}"); $this->client = new JAXLSocketClient(); $this->client->connect($this->fd); $this->client->set_callback(array(&$this, 'on_data')); } } else { _error("pipe with name {$name} already exists"); } }
public function __construct($message = null, $code = null, $file = null, $line = null) { _notice("got jaxl exception construct with {$message}, {$code}, {$file}, {$line}"); if ($code === null) { parent::__construct($message); } else { parent::__construct($message, $code); } if ($file !== null) { $this->file = $file; } if ($line !== null) { $this->line = $line; } }
public function handle_invalid_state($r) { _error("got invalid return value from state handler '" . $this->state . "', sending end stream..."); $this->send_end_stream(); $this->state = "logged_out"; _notice("state handler '" . $this->state . "' returned " . serialize($r) . ", kindly report this to developers"); }
$cmd->_("PASSED", "green"); echo "\n"; } function _notice($str) { $cmd = new CmdColors(); $cmd->_(str_pad(substr($str, 0, 55), 60), "yellow"); } $Fail = function () { _fail(); }; $Pass = function () { _pass(); }; $Notice = function ($str) { _notice($str); }; $Header = function ($str) { $cmd = new CmdColors(); $cmd->_(str_pad(substr("*----------------------------------------------------*", 0, 60), 60, ' ', STR_PAD_BOTH), "blue", "none"); echo "\n"; $cmd->_(str_pad(substr($str, 0, 60), 60, ' ', STR_PAD_BOTH), "blue", "none"); echo "\n"; $cmd->_(str_pad(substr("*----------------------------------------------------*", 0, 60), 60, ' ', STR_PAD_BOTH), "blue", "none"); echo "\n"; }; function curl_post($url, array $post = NULL, array $options = array()) { $defaults = array(CURLOPT_POST => 1, CURLOPT_HEADER => 0, CURLOPT_URL => $url, CURLOPT_FRESH_CONNECT => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FORBID_REUSE => 1, CURLOPT_TIMEOUT => 4, CURLOPT_POSTFIELDS => http_build_query($post), CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST, 2); $ch = curl_init(); // curl_setopt_array($ch, ($options + $defaults));