public function query($query = null) { $status = self::STATUS_NOTCONNECTED; $context = $this->_connection; $wrapper = $this->config('wrapper'); if ($context) { if (DevValue::isNotNull($query)) { if (DevArray::isAssoc($query)) { $this->_data = $query; } else { if (is_string($query)) { $data = urlencode($query); stream_context_set_option($context, $wrapper, 'content', $data); $this->_result = file_get_contents($target, false, $context); $this->status($this->_result !== false ? self::STATUS_SUCCESS : self::STATUS_FAILED); return true; } } } $data = HTTP::query($this->_data); stream_context_set_option($context, $wrapper, 'content', $data); $this->_result = file_get_contents($target, false, $context); if ($this->_result !== false) { $status = self::STATUS_SUCCESS; } } $this->status($status); }
public function query($query = null) { $curl = $this->_connection; $method = strtolower($this->config('method')); if ($curl) { if (DevValue::isNotNull($query)) { if (DevArray::isAssoc($query)) { //$this->_data = $query; $this->assign($query); } } $data = $this->_data; //set the url, number of POST vars, POST data if ($method == 'post') { curl_setopt($curl, CURLOPT_POST, count($data)); curl_setopt($curl, CURLOPT_POSTFIELDS, HTTP::query($data)); } elseif ($method == 'get') { curl_setopt($curl, CURLOPT_URL, $this->config('target') . '/' . HTTP::query($data)); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //execute post $this->_result = curl_exec($curl); $status = $this->_result ? self::STATUS_SUCCESS : self::STATUS_FAILED; } else { $status = self::STATUS_NOTCONNECTED; } $this->status($status); }
public function read() { $value = HTTP::cookie($this->_source); if (function_exists('json_decode')) { $value = json_decode($value); $this->contents($value); $this->loadArray((array) $value); } return $value; }
public function read() { $value = HTTP::session($this->_source); if (function_exists('json_decode')) { $value = json_decode($value); $this->contents($value); $this->assign((array) $value); } return $value; }
public function write() { $source = $this->_source; $status = self::STATUS_FAILED; $data = DevValue::isEmpty($this->_contents) ? HTTP::jsonEncode($this->_data) : $this->_contents; $source->flush(); $source->contents($data); $source->write(); $status = self::STATUS_SUCCESS; $this->status($status); }
public function query($query = null) { $socket = $this->_connection; $status = ''; if ($socket) { $method = $method ? $method : $this->config('method'); $data = HTTP::query($this->_data); $method = strtoupper($method); $request = ''; $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'PHP/' . phpversion(); if ($method == 'GET') { $request .= '/' . $this->_url . '?'; $request .= $data; $request .= "\r\n"; $request .= "User-Agent: Dev-Elation\r\n"; $request .= "Connection: Close\r\n"; $request .= "Content-Length: 0\r\n"; $cmd = "GET {$request} HTTP/1.0\r\nHost: " . $this->_host . "\r\n\r\n"; } elseif ($method == 'POSTS') { $request .= '/' . $this->_url; $request .= "\r\n"; $request .= "User-Agent: Dev-Elation\r\n"; $request .= "Content-Type: application/x-www-form-urlencoded\r\n" . ($request .= "Content-Length: " . strlen($data) . "\r\n"); $request .= $data; } else { $status = self::STATUS_FAILED; $this->status($status); return false; } $cmd = "{$method} {$request} HTTP/1.1\r\nHost: " . $this->_host . "\r\n"; fputs($sock, $cmd); while (!feof($sock)) { $data .= fgets($sock, 1024); } $this->_result = $data; $status = $this->_result ? self::STATUS_SUCCESS : self::STATUS_FAILED; } else { $status = self::STATUS_NOTCONNECTED; } $this->status($status); }
static function parachute(&$count, $max = '', $redirect = '', $log = false, $alert = false) { $max = DevValue::isNotNull($rcpt) ? $max : 400; if ($count >= $max) { $status = "Loop exceeded max count! Killing Process.\n"; if ($alert) { Util::emailAdmin($status); } if ($log) { $logger = Log::instance(array('storage' => 'log')); $logger->push($status); $logger->write(); } if (DevValue::isNotNull($redirect)) { HTTP::redirect($redirect, array('msg' => $status)); } else { exit("A script on this page began to loop out of control. Process has been killed. If you are viewing this message, please alert the administrator.\n"); } } $count++; }
public function develop() { $info = unserialize(HTTP::session(self::SESSION_VAR)); $this->fill_fields($info); $this->assign($info); }
public function send() { // echo \dev_json_encode( $this->_data ); $this->_message = HTTP::jsonEncode($this->_data); $this->dispatch(Event::COMPLETE); }
static function redirect($href = '', $request_r = '', $ssl = '', $snapshot = '') { $href = HTTP::href($href); $request = $request_r ? http_build_query($request_r) : ""; $href = str_replace('http://', '', $href); $href = str_replace('https://', '', $href); $href = ($ssl == true ? 'https' : 'http') . "://{$href}" . ($request != '' ? "?{$request}" : ""); if ($snapshot != '') { HTTP::cookie('href_snapshot', $snapshot); } header("Location: {$href}"); }