function easy_embed_rec($names, $base_info, $default_url = false) { global $base_url; $url = $default_url; $name = array_shift($names); foreach (array($name, $name . '_tablet') as $field) { if (count($names) == 0) { if (isset($base_info->{$field})) { $url = resolve_url($base_info->{$field}, $base_url); } if ($url !== false) { appdeck_add_ressource($url); } } else { if (isset($base_info->{$field})) { easy_embed_rec($names, $base_info->{$field}, $default_url); } } } }
/** *Resolves relative pdf urls to absolute * *@note pdf paths MUST BE ABSOLUTE in the fdf file or http scheme because when path contains .. then fdf fails *@param String $pdf_url any url *@return String $url the absolute url **/ function resolve_pdf_url($pdf_url) { //---------------------------------- $url = resolve_url($pdf_url); return $url; }
static function base_links($node, $base_link) { self::transform_links($node, function ($x) use($base_link) { return resolve_url($x, $base_link); }); }
/** * Enter description here... * * @param unknown_type $e * @TODO trigger submit for form after form's submit button has a click event */ public static function handleSubmit($e, $callback = null) { $node = phpQuery::pq($e->target); if (!$node->is('form') || !$node->is('[action]')) { return; } // TODO document.location $xhr = isset($node->document->xhr) ? $node->document->xhr : null; $submit = pq($e->relatedTarget)->is(':submit') ? $e->relatedTarget : $node->find('*:submit:first')->get(0); $data = array(); foreach ($node->serializeArray($submit) as $r) { // XXXt.c maybe $node->not(':submit')->add($sumit) would be better ? // foreach($node->serializeArray($submit) as $r) $data[$r['name']] = $r['value']; } $options = array('type' => $node->attr('method') ? $node->attr('method') : 'GET', 'url' => resolve_url($e->data[0], $node->attr('action')), 'data' => $data, 'referer' => $node->document->location); if ($node->attr('enctype')) { $options['contentType'] = $node->attr('enctype'); } $xhr = phpQuery::ajax($options, $xhr); if ((!$callback || !$callback instanceof Callback) && $e->data[1]) { $callback = $e->data[1]; } if ($xhr->getLastResponse()->isSuccessful() && $callback) { phpQuery::callbackRun($callback, array(self::browserReceive($xhr))); } }
function easy_embed_rec($names, $base_info) { global $base_url; $name = array_shift($names); $count = 0; foreach (array($name, $name . '_tablet', $name . '_phone', $name . '_tablet_ios', $name . '_phone_ios', $name . '_tablet_android', $name . '_phone_android', $name . '_ios', $name . '_android') as $field) { if (count($names) == 0) { if (isset($base_info->{$field})) { $url = resolve_url($base_info->{$field}, $base_url); appdeck_add_ressource($url); $count++; } } else { if (isset($base_info->{$field})) { easy_embed_rec($names, $base_info->{$field}); $count++; } } } return $count; }
{ $scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST']; $path = rtrim(dirname($_SERVER['PHP_SELF']), '/'); return "{$scheme}://{$host}{$path}/{$file}"; } $fp = fopen("/tmp/goose_lock.txt", "w+"); if (flock($fp, LOCK_EX)) { $author = $_SERVER['REMOTE_USER']; $path = $_SERVER['DOCUMENT_ROOT'] . "/../pages"; $file = $_REQUEST['file']; $content = preg_replace('/\\r(\\n)?/', "\n", $_REQUEST['content']); $log = $_REQUEST['log']; // echo "Write to: $path/$file.page<br>\n"; if ($page = fopen($path . '/' . $file . '.page', 'w')) { fwrite($page, $content); fclose($page); // echo "Run: cd $path && git add $file.page && git commit -m '$log' --author='$author <>' && cd .. && make<br>\n"; if ($cmd = popen("cd {$path} && git add {$file}.page && git commit -m '{$log}' --author='{$author} <>' && cd .. && make", 'r')) { while ($line = fgets($cmd)) { } // echo $line . "<br>\n"; pclose($cmd); header('Location: ' . resolve_url("../{$file}")); } } flock($fp, LOCK_UN); } else { echo "Couldn't lock the file !"; } fclose($fp);
function display_from_archive($content_map = array()) { // Set default values $this->params = array_merge(array('pattern' => '@^[/]([^/]+)[/](.*)$@', 'vpath' => $_SERVER["PATH_INFO"], 'archive_subdir' => true, 'zipfile' => true, 'fix_dir' => false, 'archive_dir' => ARCHIVE_DIR, 'archive_file_prefix' => ARCHIVE_FILE_PREFIX, 'use_http_expire_date' => false, 'override_extractor' => null, 'title' => NULL, 'charset' => NULL, 'content' => NULL, 'error' => false), $this->params); $this->get_archive_location(); // Only use a permanent redirect for releases (beta or full). $redirect_status_code = $this->params['version'] && $this->params['version']->is_numbered_release() ? 301 : 302; // Calculate expiry date if requested. $expires = null; if ($this->params['use_http_expire_date']) { if (!$this->params['version']) { $expires = "+1 week"; } else { $compare_version = BoostVersion::from($this->params['version'])->compare(BoostVersion::current()); $expires = $compare_version === -1 ? "+1 year" : ($compare_version === 0 ? "+1 week" : "+1 day"); } } // Check file exists. if ($this->params['zipfile']) { $check_file = $this->params['archive']; if (!is_readable($check_file)) { error_page($this->params, 'Unable to find zipfile.'); return; } } else { $check_file = $this->params['file']; if (is_dir($check_file)) { if (substr($check_file, -1) != '/') { $redirect = resolve_url(basename($check_file) . '/'); header("Location: {$redirect}", TRUE, $redirect_status_code); return; } $found_file = NULL; if (is_readable("{$check_file}/index.html")) { $found_file = 'index.html'; } else { if (is_readable("{$check_file}/index.htm")) { $found_file = 'index.htm'; } } if ($found_file) { $this->params['file'] = $check_file = $check_file . $found_file; $this->params['key'] = $this->params['key'] . $found_file; } else { if (!http_headers('text/html', filemtime($check_file), $expires)) { return; } $display_dir = new BoostDisplayDir($this->params); return $display_dir->display($check_file); } } else { if (!is_readable($check_file)) { error_page($this->params, 'Unable to find file.'); return; } } } // Choose filter to use $info_map = array_merge($content_map, array(array('', '@[.](txt|py|rst|jam|v2|bat|sh|xml|xsl|toyxml)$@i', 'text', 'text/plain'), array('', '@[.](qbk|quickbook)$@i', 'qbk', 'text/plain'), array('', '@[.](c|h|cpp|hpp)$@i', 'cpp', 'text/plain'), array('', '@[.]png$@i', 'raw', 'image/png'), array('', '@[.]gif$@i', 'raw', 'image/gif'), array('', '@[.](jpg|jpeg|jpe)$@i', 'raw', 'image/jpeg'), array('', '@[.]svg$@i', 'raw', 'image/svg+xml'), array('', '@[.]css$@i', 'raw', 'text/css'), array('', '@[.]js$@i', 'raw', 'application/x-javascript'), array('', '@[.]pdf$@i', 'raw', 'application/pdf'), array('', '@[.](html|htm)$@i', 'raw', 'text/html'), array('', '@(/|^)(Jamroot|Jamfile|ChangeLog|configure)$@i', 'text', 'text/plain'), array('', '@[.]dtd$@i', 'raw', 'application/xml-dtd'))); $preprocess = null; $extractor = null; $type = null; foreach ($info_map as $i) { if (preg_match($i[1], $this->params['key'])) { if ($i[0]) { $version = BoostVersion::from($i[0]); if ($version->compare(BoostVersion::page()) > 0) { // This is after the current version. continue; } } $extractor = $i[2]; $type = $i[3]; $preprocess = isset($i[4]) ? $i[4] : NULL; break; } } if ($this->params['override_extractor']) { $extractor = $this->params['override_extractor']; } if (!$extractor) { if (strpos($_SERVER['HTTP_HOST'], 'www.boost.org') === false) { error_page($this->params, "No extractor found for filename."); } else { error_page($this->params); } return; } // Handle ETags and Last-Modified HTTP headers. // Output raw files. if ($extractor == 'raw') { if (!http_headers($type, filemtime($check_file), $expires)) { return; } display_raw_file($this->params, $_SERVER['REQUEST_METHOD'], $type); } else { // Read file from hard drive or zipfile // Note: this sets $this->params['content'] with either the // content or an error message. if (!extract_file($this->params)) { error_page($this->params, $this->params['content']); return; } // Check if the file contains a redirect. if ($type == 'text/html') { if ($redirect = detect_redirect($this->params['content'])) { http_headers('text/html', null, "+1 day"); header("Location: {$redirect}", TRUE, $redirect_status_code); if ($_SERVER['REQUEST_METHOD'] != 'HEAD') { echo $this->params['content']; } return; } } if (!http_headers('text/html', filemtime($check_file), $expires)) { return; } // Finally process the file and display it. if ($_SERVER['REQUEST_METHOD'] != 'HEAD') { if ($preprocess) { $this->params['content'] = call_user_func($preprocess, $this->params['content']); } echo_filtered($extractor, $this->params); } } }
public function set_module($module_name, $module_path) { assert(!isset($this->details['module'])); $module_path = trim($module_path, '/') . '/'; $documentation_url = isset($this->details['documentation']) ? $this->details['documentation'] : '.'; $this->details['module'] = $module_name; $this->details['documentation'] = ltrim(resolve_url($documentation_url, $module_path), '/'); }
function easy_embed($name, $default_url = false) { global $base_url, $info; $url = $default_url; foreach (array($name, $name . '_tablet') as $field) { if (isset($info->{$field})) { $url = resolve_url($info->{$field}, $base_url); } if ($url !== false && $field == $name) { appdeck_add_ressource($url); } } }
private function rewrite_link_helper($m) { // 1=pre, 2=url, 3=post // false positive: Typical javascript like // var foo = '<img src="'+other_variable[i]+'">'; // skip these things. if ($m[2][0] == '"' || $m[2][0] == "'") { return $m[1] . $m[2] . $m[3]; } // 1. step: resolve absolute URL (if e.g. relative given) // 2. step: deproxify (only neccessary if absolute was given) return $m[1] . $this->conf->deproxify(resolve_url($this->rewrite_url, $m[2])) . $m[3]; }
if ($info == false) { appdeck_error("{$app_json_url}: invalid json data: {$json_data}"); } $base_url = isset($info->base_url) ? $info->base_url : $app_json_url; if (!isset($info->embed_url) && !isset($info->embed)) { appdeck_warning("no embed ressources defined in app.json"); } // by default we always embed app.json appdeck_add_ressource($app_json_url, $json_data, true); // try to add files from embed url if (isset($info->embed_url)) { $embed_url = resolve_url($info->embed_url, $base_url); embed_url($embed_url); } if (isset($info->embed_url_tablet)) { $embed_url = resolve_url($info->embed_url_tablet, $base_url); embed_url($embed_url); } // inline embed urls if (isset($info->embed)) { foreach ($info->embed as $line) { if (trim($line) != "") { appdeck_add_ressource(trim($line)); } } } // http://appdata.static.appdeck.mobi/res/ios/icons/action_dark.png // http://appdata.static.appdeck.mobi/res/ios/icons/action.png // http://appdata.static.appdeck.mobi/res/ios7/icons/action_dark.png // http://appdata.static.appdeck.mobi/res/ios7/icons/action.png // http://appdata.static.appdeck.mobi/res/android/icons/action_dark.png
// by default we always embed app.json appdeck_add_ressource($app_json_url, $json_data, true); // try to add files from embed url if (isset($info->embed_url)) { $embed_url = resolve_url($info->embed_url, $base_url); embed_url($embed_url); } if (isset($info->embed_url_tablet)) { $embed_url = resolve_url($info->embed_url_tablet, $base_url); embed_url($embed_url); } // inline embed urls if (isset($info->embed)) { foreach ($info->embed as $line) { if (trim($line) != "") { $url = resolve_url(trim($line), $base_url); appdeck_add_ressource($url); } } } // http://appdata.static.appdeck.mobi/res/ios/icons/action_dark.png // http://appdata.static.appdeck.mobi/res/ios/icons/action.png // http://appdata.static.appdeck.mobi/res/ios7/icons/action_dark.png // http://appdata.static.appdeck.mobi/res/ios7/icons/action.png // http://appdata.static.appdeck.mobi/res/android/icons/action_dark.png // http://appdata.static.appdeck.mobi/res/android/icons/action.png $icon_theme = ''; if (isset($info->icon_theme) && strtolower($info->icon_theme) == 'dark') { $icon_theme = '_dark'; } easy_embed("icon_action", "http://appdata.static.appdeck.mobi/res/" . EMBED_TYPE . "/icons/action{$icon_theme}.png");
/** @private sub-callback for preg_replace_callback in process_inline() */ function process_inline_cb_external_link($matches) { $url = $matches[1]; $title = count($matches) > 2 ? $matches[2] : $url; return '<a href="' . $this->escape_quotes(resolve_url($url)) . '">' . $title . '</a>'; }
/** * 5. Downloads social profile and sets all (or only social) user or person information from it * @param object $user_or_person * @param string $social_network - see 1. * @param string $username - see 1. * @param boolean $new - true if it is a new user/person, or false when it is existing user/person * @return boolean */ function set_all_info_from_social(&$user_or_person, $social_network, $username = '', $new = false) { if ($username) { switch ($social_network) { case 'twitter': if ($username != $user_or_person->twitter_username) { // get twitter information $tw_data = get_social_profile($social_network, $username); if (isset($tw_data->id) && $tw_data->id && isset($tw_data->screen_name) && $tw_data->screen_name) { // profile exists $user_or_person->twitter_username = $username; $user_or_person->twitter_id = $tw_data->id; $user_or_person->twitter_name = isset($tw_data->name) ? $tw_data->name : ''; $user_or_person->twitter_img_url = isset($tw_data->profile_image_url) ? $tw_data->profile_image_url : ''; $user_or_person->twitter_verified = isset($tw_data->verified) ? $tw_data->verified : ''; if ($new) { // setting person info from twitter data if ($user_or_person->fullname == '' && isset($tw_data->name)) { $user_or_person->fullname = $tw_data->name; } if ($user_or_person->bio == '' && isset($tw_data->description)) { $user_or_person->bio = $tw_data->description; } if ($user_or_person->location == '' && isset($tw_data->location)) { $user_or_person->location = $tw_data->location; } if ($user_or_person->web == '' && isset($tw_data->url)) { $user_or_person->web = resolve_url($tw_data->url); } $user_or_person->picture_url = $user_or_person->twitter_img_url; } return true; } else { // can't get twitter data return false; } } else { // same twitter username, no overwrite return true; } break; case 'linkedin': if ($username != $user_or_person->linkedin_username) { // get linkedin information $in_user = get_social_profile($social_network, $username); if ($in_user) { // we have linkedin data $user_or_person->linkedin_username = $username; $user_or_person->linkedin_id = isset($in_user->id) ? $in_user->id : ''; $user_or_person->linkedin_name = isset($in_user->formattedName) ? $in_user->formattedName : ''; $user_or_person->linkedin_img_url = isset($in_user->pictureUrl) ? $in_user->pictureUrl : ''; if ($user_or_person->firstname == '' && isset($in_user->firstName)) { $user_or_person->firstname = $in_user->firstName; } if ($user_or_person->lastname == '' && isset($in_user->lastName)) { $user_or_person->lastname = $in_user->lastName; } if ($new) { // setting person info from linkedin data if ($user_or_person->fullname == '') { $user_or_person->fullname = isset($in_user->formattedName) ? $in_user->formattedName : $user_or_person->firstname . ' ' . $user_or_person->lastname; } if ($user_or_person->bio == '' && isset($in_user->headline)) { $user_or_person->bio = $in_user->headline; } if ($user_or_person->location == '' && isset($in_user->location->name)) { $user_or_person->location = $in_user->location->name; } // can't get web address from linkedin yet - will come here later // $user->web = ''; if ($user_or_person->picture_url == '') { $user_or_person->picture_url = $user_or_person->linkedin_img_url; } } return true; } else { // can't get linkedin data return false; } } else { // same linkedin username, no overwrite return true; } break; case 'facebook': if ($username != $user_or_person->facebook_username) { // get facebook info $fb_graph = get_social_profile($social_network, $username); if (isset($fb_graph->id) && isset($fb_graph->first_name)) { // make sure it's a person, not some object $user_or_person->facebook_username = $username; $user_or_person->facebook_id = $fb_graph->id; $user_or_person->facebook_name = isset($fb_graph->name) ? $fb_graph->name : ''; $user_or_person->facebook_img_url = 'https://graph.facebook.com/' . $username . '/picture'; $user_or_person->facebook_gender = isset($fb_graph->gender) ? $fb_graph->gender : ''; if ($user_or_person->firstname == '') { $user_or_person->firstname = $fb_graph->first_name; } if ($user_or_person->lastname == '' && isset($fb_graph->last_name)) { $user_or_person->lastname = $fb_graph->last_name; } if ($new) { if ($user_or_person->fullname == '') { $user_or_person->fullname = isset($fb_graph->name) ? $fb_graph->name : $fb_graph->first_name . ' ' . $user_or_person->lastname; } if ($user_or_person->picture_url == '') { $user_or_person->picture_url = $user_or_person->facebook_img_url; } } return $fb_graph; } else { // can't get facebook data return false; } } else { // same facebook username, no overwrite return true; } break; default: return false; } } elseif (!$new) { // username is empty, but overwrite is true - we will clear social fields // a hack, really, out of lazyness to create another function... clear_social_info($user_or_person, $social_network); return true; } else { return false; } }
if ($response->getResponseCode() >= 400) { // Error codes. Redirect client to error page so he // can see the mess on his own ;-) header("Location: {$url}"); exit; } if ($response->getResponseCode() != 301 && $response->getResponseCode() != 302) { // no redirection codes, go on in program... break; } // else: redirection codes. // problem: Can be relative. Get absolute! // (since HttpRequest won't remember the host) $new_url = $response->getHeader('Location'); // get absolute url, proxified, and set to new Location. $response->addHeaders(array('Location' => $conf->proxify(resolve_url($url, $new_url)))); // Take care: This will *NOT* rewrite the body, where the // Redirection URL will probably also be send for old browsers. // Don't follow yourself the new location but tell it the client // since relative links otherwise won't work any more! $response->send(); exit; // that was a nasty bug to detect... took me hours // $request->setUrl( resolve_url($url, $new_url) ); } while (1); #$max_follow_redirects-- > 0); if (!$max_follow_redirects) { throw new MsException("Got rewriting loop while redirecting to {$url}!"); } // now we've got our request finished... (at first ;-) ) } catch (HttpException $ex) {
/** * 11a. Logs in / signs up twitter user */ public function login_twitter_user($tw_user_id) { if ($tw_user_id) { $query = $this->db->where('twitter_id', $tw_user_id)->get('users'); if ($query->num_rows() === 1) { // user found $user = new dbUser(); $user->copy($query->row()); $user->password = $user->password ? '***' : ''; return $user; } else { // no such user, signing up $this->load->library('twconnect'); $user = new dbFullUser(); $user->twitter_id = $tw_user_id; $user->twitter_token = $this->twconnect->tw_access_token['oauth_token']; $user->twitter_token_secret = $this->twconnect->tw_access_token['oauth_token_secret']; $user->twitter_username = $this->twconnect->tw_user_name; $this->twconnect->twaccount_verify_credentials(); // this will get us user info if ($this->twconnect->tw_user_info) { // we have extended user info $user->fullname = $this->twconnect->tw_user_info->name; $user->bio = $this->twconnect->tw_user_info->description; $user->location = $this->twconnect->tw_user_info->location; $user->web = resolve_url($this->twconnect->tw_user_info->url); $user->twitter_name = $this->twconnect->tw_user_info->name; $user->twitter_img_url = $this->twconnect->tw_user_info->profile_image_url; $user->twitter_verified = $this->twconnect->tw_user_info->verified; $user->picture_url = $user->twitter_img_url; $user->big_picture_url = resolve_url('https://api.twitter.com/1/users/profile_image?screen_name=' . $user->twitter_username . '&size=bigger'); } else { // we failed to get extended user info, but we will try to get it differently via public api request $ok = set_all_info_from_social($user, 'twitter', $user->twitter_username, true); if (!$ok) { // we do not have twitter data $user->fullname = $user->twitter_username; } } // Inserting user $ok = $this->db->insert('users', $user); // we don't have id yet... $user->id = $this->db->insert_id(); $this->meet_WhoYouMeet_team($user); return $user; if (!$ok) { // Cannot insert user return false; } } // end of else - no such user, signing user up } else { // no $tw_user_id passed return false; } }