function main() { global $ACCESS_TOKEN, $USER_AGENT; // Set the API sport, method, id, format, and any parameters $host = 'erikberg.com'; $sport = ''; $method = 'events'; $id = ''; $format = 'json'; $parameters = array('sport' => 'nba', 'date' => '20130414'); // Pass method, format, and parameters to build request url $url = buildURL($host, $sport, $method, $id, $format, $parameters); // Set the User Agent, Authorization header and allow gzip $default_opts = array('http' => array('user_agent' => $USER_AGENT, 'header' => array('Accept-Encoding: gzip', 'Authorization: Bearer ' . $ACCESS_TOKEN))); stream_context_get_default($default_opts); $file = 'compress.zlib://' . $url; $fh = fopen($file, 'rb'); if ($fh && strpos($http_response_header[0], "200 OK") !== false) { $content = stream_get_contents($fh); fclose($fh); printResult($content); } else { // handle error, check $http_response_header for HTTP status code, etc. if ($fh) { $xmlstats_error = json_decode(stream_get_contents($fh)); printf("Server returned %s error along with this message:\n%s\n", $xmlstats_error->error->code, $xmlstats_error->error->description); } else { print "A problem was encountered trying to connect to the server!\n"; print_r(error_get_last()); } } }
function idpage_render($identity) { $xrdsurl = buildURL('userXrds') . "?user=" . urlencode($identity); $headers = array('X-XRDS-Location: ' . $xrdsurl); $body = sprintf(idpage_pat, buildURL(), $xrdsurl); return array($headers, $body); }
function getServer() { static $server = null; if (!isset($server)) { $server =& new Auth_OpenID_Server(getOpenIDStore(), buildURL()); } return $server; }
function trust_render($info) { $current_user = getLoggedInUser(); $lnk = link_render($current_user); $trust_root = htmlspecialchars($info->trust_root); $trust_url = buildURL('trust', true); $form = sprintf(trust_form_pat, $lnk, $trust_root, $trust_url); return page_render($form, $current_user, 'Trust This Site'); }
/** * Handle a standard OpenID server request */ function action_default() { header('X-XRDS-Location: ' . buildURL('idpXrds')); $server =& getServer(); $method = $_SERVER['REQUEST_METHOD']; $request = null; if ($method == 'GET') { $request = $_GET; } else { $request = $_POST; } $request = $server->decodeRequest(); if (!$request) { return about_render(); } setRequestInfo($request); if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) { if ($request->idSelect()) { // Perform IDP-driven identifier selection if ($request->mode == 'checkid_immediate') { $response =& $request->answer(false); } else { return trust_render($request); } } else { if (!$request->identity && !$request->idSelect()) { // No identifier used or desired; display a page saying // so. return noIdentifier_render(); } else { if ($request->immediate) { $response =& $request->answer(false, buildURL()); } else { /* if (!getLoggedInUser()) { return login_render(); } */ return trust_render($request); } } } } else { $response =& $server->handleRequest($request); } $webresponse =& $server->encodeResponse($response); if ($webresponse->code != AUTH_OPENID_HTTP_OK) { header(sprintf("HTTP/1.1 %d ", $webresponse->code), true, $webresponse->code); } foreach ($webresponse->headers as $k => $v) { header("{$k}: {$v}"); } header(header_connection_close); print $webresponse->body; exit(0); }
/** * Render the about page, potentially with an error message */ function about_render($error = false, $internal = true) { $headers = array(); $body = sprintf(about_body, buildURL()); if ($error) { $headers[] = $internal ? http_internal_error : http_bad_request; $body .= sprintf(about_error_template, htmlspecialchars($error)); } $current_user = getLoggedInUser(); return page_render($body, $current_user, 'OpenID Server Endpoint'); }
function sites_render($sites) { if ($sites) { $rows = siteList_render($sites); $form = sprintf(sites_form, buildURL('sites'), $rows); $body = $pre . $form; } else { $body = sprintf(sites_empty_message, link_render(buildURL(''), 'Return home')); } return page_render($body, getLoggedInUser(), 'Remembered Sites'); }
function trust_render($info) { $current_user = getLoggedInUser(); $lnk = link_render(idURL($current_user)); $trust_root = htmlspecialchars($info->trust_root); $trust_url = buildURL('trust', true); if ($info->idSelect()) { $prompt = id_select_pat; } else { $prompt = sprintf(normal_pat, $lnk, $trust_root); } $form = sprintf(trust_form_pat, $trust_url, $prompt); return page_render($form, $current_user, 'Trust This Site'); }
function apiCall($apiCall, $site, $filter) { global $apiKey; $url = buildURL($apiCall, $site, $filter, $apiKey); $ch = curl_init($url); curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); if ($result === false) { $error = curl_error($ch); curl_close($ch); throw new Exception("Error calling Stack Exchange API: {$error}"); } curl_close($ch); return $result; }
function login_render($errors = null, $input = null, $needed = null) { $current_user = getLoggedInUser(); if ($input === null) { $input = $current_user; } if ($needed) { $errors[] = sprintf(login_needed_pat, link_render($needed)); } $esc_input = htmlspecialchars($input, ENT_QUOTES); $login_url = buildURL('login', true); $body = sprintf(login_form_pat, $login_url, $esc_input); if ($errors) { $body = loginError_render($errors) . $body; } return page_render($body, $current_user, 'Log In', null, true); }
function action_show_trust() { $server =& getServer(); $info = getRequestInfo(); if (!$info) { $info = $server->decodeRequest(); setRequestInfo($info); } $geni_user = geni_loadUser(); $req_url = idURL($geni_user->username); $trust_root = htmlspecialchars($info->trust_root); $title = 'GENI OpenID Trust'; $authorize_url = buildURL('authorize', true); $text = make_trust_page($geni_user, $title, $trust_root, $authorize_url); $headers = array(); return array($headers, $text); }
function getAbsoluteStartPage() { global $us; $urlParts = getCurrentURL(); $parts = parse_url($us->getProperty('badgerStartPage')); $urlParts['path'] = BADGER_ROOT . '/' . $parts['path']; if (isset($parts['query'])) { $urlParts['query'] = $parts['query']; } else { unset($urlParts['query']); } if (isset($parts['fragment'])) { $urlParts['fragment'] = $parts['fragment']; } else { unset($urlParts['fragment']); } return buildURL($urlParts); }
function navigation_render($msg, $items) { $what = link_render(buildURL(), 'PHP OpenID Server'); if ($msg) { $what .= ' — ' . $msg; } if ($items) { $s = '<p>' . $what . '</p><ul class="bottom">'; foreach ($items as $action => $text) { $url = buildURL($action); $s .= sprintf('<li>%s</li>', link_render($url, $text)); } $s .= '</ul>'; } else { $s = '<p class="bottom">' . $what . '</p>'; } return sprintf('<div class="navigation">%s</div>', $s); }
/** * Render an HTML page */ function page_render($body, $user, $title, $h1 = null, $login = false) { $h1 = $h1 ? $h1 : $title; if ($user) { $msg = sprintf(logged_in_pat, link_render($user)); $nav = array('logout' => 'Log Out', 'sites' => 'Remembered Sites'); $navigation = navigation_render($msg, $nav); } else { if (!$login) { $msg = link_render(buildURL('login'), 'Log In'); $navigation = navigation_render($msg, array()); } else { $navigation = ''; } } $style = getStyle(); $text = sprintf(page_template, $title, $style, $navigation, $h1, $body); // No special headers here $headers = array(); return array($headers, $text); }
function idpXrds_render() { $headers = array('Content-type: application/xrds+xml'); $body = sprintf(idp_xrds_pat, Auth_OpenID_TYPE_2_0_IDP, buildURL()); return array($headers, $body); }
$arPages[] = buildURL("Useful Links", "Site Map", "/sitemap", 'weekly', '0.50'); if ($page->userdata != null) { $arPages[] = buildURL("Useful Links", "Rss Feeds", "/rss", 'weekly', '0.50'); $arPages[] = buildURL("Useful Links", "API", "/apihelp", 'weekly', '0.50'); $arPages[] = buildURL("Nzb", "Search Nzb", "/search", 'weekly', '0.50'); $arPages[] = buildURL("Nzb", "Search Raw", "/searchraw", 'daily', '0.80'); $arPages[] = buildURL("Nzb", "Browse Nzb", "/browse", 'daily', '0.80'); $arPages[] = buildURL("Nzb", "Browse Groups", "/browsegroup", 'daily', '0.80'); $arPages[] = buildURL("Nzb", "Movies", "/movies", 'daily', '0.80'); $arPages[] = buildURL("Nzb", "TV Series", "/series", 'daily', '0.80'); $arPages[] = buildURL("Nzb", "Anime", "/anime", 'daily', '0.80'); $arPages[] = buildURL("Nzb", "Music", "/music", 'daily', '0.80'); $arPages[] = buildURL("Nzb", "Console", "/console", 'daily', '0.80'); $arPages[] = buildURL("Forum", "Forum", "/forum", 'daily', '0.80'); $arPages[] = buildURL("User", "Cart", "/cart", 'weekly', '0.50'); $arPages[] = buildURL("User", "Profile", "/profile", 'weekly', '0.50'); } // // echo appropriate site map // asort($arPages); $page->smarty->assign(['sitemaps' => $arPages, 'last_type' => '']); if (isset($_GET["type"]) && $_GET["type"] == "xml") { echo $page->smarty->fetch('sitemap-xml.tpl'); } else { $page->title = $page->settings->getSetting('title') . " site map"; $page->meta_title = $page->settings->getSetting('title') . " site map"; $page->meta_keywords = "sitemap,site,map"; $page->meta_description = $page->settings->getSetting('title') . " site map shows all our pages."; $page->content = $page->smarty->fetch('sitemap.tpl'); $page->render();
} // // articles // $contentlist = $contents->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role); foreach ($contentlist as $content) { $arPages[] = buildURL("Articles", $content->title, '/content/' . $content->id . $content->url, 'monthly', '0.50'); } // // static pages // $arPages[] = buildURL("Useful Links", "Contact Us", "/contact-us", 'yearly', '0.30'); $arPages[] = buildURL("Useful Links", "Site Map", "/sitemap", 'weekly', '0.50'); $arPages[] = buildURL("Useful Links", "Rss Feeds", "/rss", 'weekly', '0.50'); $arPages[] = buildURL("Nzb", "Search Nzb", "/search", 'weekly', '0.50'); $arPages[] = buildURL("Nzb", "Browse Nzb", "/browse", 'daily', '0.80'); // // echo appropriate site map // asort($arPages); $page->smarty->assign('sitemaps', $arPages); if (isset($_GET["type"]) && $_GET["type"] == "xml") { echo $page->smarty->fetch('sitemap-xml.tpl'); } else { $page->title = $page->site->title . " site map"; $page->meta_title = $page->site->title . " site map"; $page->meta_keywords = "sitemap,site,map"; $page->meta_description = $page->site->title . " site map shows all our pages."; $page->content = $page->smarty->fetch('sitemap.tpl'); $page->render(); }
/** * Handle a standard OpenID server request */ function action_default() { header('X-XRDS-Location: ' . buildURL('idpXrds')); $server =& getServer(); $method = $_SERVER['REQUEST_METHOD']; $request = null; if ($method == 'GET') { $request = $_GET; } else { $request = $_POST; } $request = $server->decodeRequest(); if (!$request) { return about_render(); } setRequestInfo($request); if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) { // Redirect to indirect server here with a 307 code to redirect // the POST to the new location. Normal redirect (without 307) // causes a GET instead of a POST global $indirect_server_url; $new_location = $indirect_server_url; if ($method == 'GET') { // If the request comes in via get, we want to redirect // to a URL that includes the full query string. Otherwise // all that juicy data gets lost. This was a problem for GIMI, // which uses a ruby openid client. $new_location .= '?' . $_SERVER['QUERY_STRING']; } else { if ($method == 'POST') { $query = Auth_OpenID::getQuery(); $new_location .= '?' . http_build_query($query); } } header('Location: ' . $new_location, true, 307); exit; if ($request->idSelect()) { // Perform IDP-driven identifier selection if ($request->mode == 'checkid_immediate') { $response =& $request->answer(false); } else { return trust_render($request); } } else { if (!$request->identity && !$request->idSelect()) { // No identifier used or desired; display a page saying // so. return noIdentifier_render(); } else { if ($request->immediate) { $response =& $request->answer(false, buildURL()); } else { if (!getLoggedInUser()) { return login_render(); } return trust_render($request); } } } } else { $response =& $server->handleRequest($request); } $webresponse =& $server->encodeResponse($response); if ($webresponse->code != AUTH_OPENID_HTTP_OK) { header(sprintf("HTTP/1.1 %d ", $webresponse->code), true, $webresponse->code); } foreach ($webresponse->headers as $k => $v) { header("{$k}: {$v}"); } header(header_connection_close); print $webresponse->body; exit(0); }
function idURL($identity) { return buildURL('idpage') . "?user=" . $identity; }
} } if ($found) { return $datasetID; } else { return null; } } function buildURL($datasetID, $assignmentID, $workerID, $url = 'form.php') { $url .= '?dataset=' . $datasetID . '&assignmentId=' . $assignmentID . '&workerId=' . $workerID; return $url; } $dsid = findDataSet($workerID); if (!is_null($dsid)) { $url = buildURL($dsid, $assignmentID, $workerID); //echo $url; //header('Location: '.$url); ?> <script type="text/javascript"> $(document).ready(function(){ $('#agree').click(function(){ window.location.replace('<?php echo $url; ?> '); });
<?php /* * ____ _____ _____ ______ _____ *| _ \ /\ | __ \ / ____| ____| __ \ *| |_) | / \ | | | | | __| |__ | |__) | *| _ < / /\ \ | | | | | |_ | __| | _ / *| |_) / ____ \| |__| | |__| | |____| | \ \ *|____/_/ \_\_____/ \_____|______|_| \_\ * Open Source Financial Management * Visit http://badger.berlios.org * **/ require_once BADGER_ROOT . '/core/urlTools.php'; require_once BADGER_ROOT . '/core/update/common.php'; if (getBadgerDbVersion() !== BADGER_VERSION) { $urlParts = getCurrentURL(); if (substr($urlParts['path'], -23) !== '/core/update/update.php') { $urlParts['path'] = BADGER_ROOT . '/core/update/update.php'; unset($urlParts['query']); unset($urlParts['fragment']); $url = buildURL($urlParts); $logger->log('Update: Redirect to Update URL: ' . $url); header('Location: ' . $url); exit; } }
function userXrds_render($identity) { $headers = array('Content-type: application/xrds+xml'); $body = sprintf(xrds_pat, Auth_OpenID_TYPE_2_0, Auth_OpenID_TYPE_1_1, buildURL()); return array($headers, $body); }
// $user_data = array('id' => 11353, 'termination_date' => '02-Jul-09'); $result = postToURL(buildURL('APIUser', 'setUser'), array($user_data)); if ($result === TRUE) { echo "Employee data saved successfully.<br>\n"; } else { echo "Employee save failed.<br>\n"; print $result; //Show error messages } // //Add new employee, several new employees can be added in a single operation as well. // $user_data = array('status_id' => 10, 'first_name' => 'Michael', 'last_name' => 'Jackson', 'employee_number' => 239842, 'user_name' => 'mjackson', 'password' => 'whiteglove123', 'hire_date' => '01-Oct-09', 'currency_id' => 3); $result = postToURL(buildURL('APIUser', 'setUser'), array($user_data)); if ($result !== FALSE) { echo "Employee added successfully.<br>\n"; $insert_id = $result; //Get employees new ID on success. } else { echo "Employee save failed.<br>\n"; print $result; //Show error messages } // //Get TimeSheet Summary report data in raw PHP native array format. 'csv' and 'pdf' are also valid formats. // $config = postToURL(buildURL('APITimesheetSummaryReport', 'getTemplate'), array('by_employee+regular+overtime+premium+absence')); $result = postToURL(buildURL('APITimesheetSummaryReport', 'getTimesheetSummaryReport'), array($config, 'raw')); echo "Report Data: <br>\n"; var_dump($result);
function getProductInformation($pid, $utm_s, $utm_m, $utm_c, $size = 'list') { $info = array(); if (isset($pid) && !empty($pid)) { global $link; $temp = 0; $product = SolrSearch::getProductsForIDs(array($pid), $temp); $product = $product[0]; $info['name'] = strtoupper((string) $product["name"]); $info['description'] = (string) $product['description']; $info['price'] = round($product["mrp"]); $info['sprice'] = round($product["offer_price"]); $info['url'] = buildURL((string) $product["product_link"], $utm_s, $utm_m, $utm_c); $info['image'] = (string) $product["image_link_{$size}"]; //echo "<pre>"; print_r( $info ); exit; } return $info; }