HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: /home/httpd/html/baretube.com/xprofiles.functions.php
<?php
function rest_helper($url, $params = null, $verb = 'GET', $format = 'json') {
			  $cparams = array(
				'http' => array(
				  'method' => $verb,
				  'ignore_errors' => true
				)
			  );
			  if ($params !== null) {
				$params = http_build_query($params);
				if ($verb == 'POST') {
				  $cparams['http']['content'] = $params;
				} else {
				  $url .= '?' . $params;
				}
			  }
			
			  $context = stream_context_create($cparams);
			  $fp = fopen($url, 'rb', false, $context);
			  if (!$fp) {
				$res = false;
			  } else {
				// If you're trying to troubleshoot problems, try uncommenting the
				// next two lines; it will show you the HTTP response headers across
				// all the redirects:
				// $meta = stream_get_meta_data($fp);
				// var_dump($meta['wrapper_data']);
				$res = stream_get_contents($fp);
			  }
			
			  if ($res === false) {
				throw new Exception("$verb $url failed: $php_errormsg");
			  }
			
			  switch ($format) {
				case 'json':
				  $r = json_decode($res);
				  if ($r === null) {
					throw new Exception("failed to decode $res as json");
				  }
				  return $r;
				case 'xml':
				  $r = simplexml_load_string($res);
				  if ($r === null) {
					throw new Exception("failed to decode $res as xml");
				  }
				  return $r;
			  }
			  return $res;
			}
?>