/** * Uses two-legged OAuth to respond to a Google documents list API request * @param string $base_feed Full URL of the resource to access * @param array $params (optional) parameters to be added to url line * @param string $type The HTTP method (GET, POST, PUT, DELETE) * @param string $postData (optional) POST/PUT request body * @param string $version (optional) if not sent will be set to 3.0 * @param string $content_type (optional) what kind of content is being sent * @param string $slug (optional) used in determining the revision of a document * @param boolean $batch is this a batch transmission? * @return string $response body from the server */ function twolegged($base_feed, $params, $type, $postdata = null, $version = null, $content_type = null, $slug = null, $batch = null) { global $CFG; require_once $CFG->dirroot . '/repository/morsle/lib.php'; // for morsle_decode require_once $CFG->dirroot . '/google/oauth.php'; // Establish an OAuth consumer based on our admin 'credentials' if (!($CONSUMER_KEY = get_config('morsle', 'consumer_key'))) { return NULL; } if (!($CONSUMER_SECRET = get_config('morsle', 'oauthsecretstr'))) { return NULL; } $CONSUMER_SECRET = morsle_decode($CONSUMER_SECRET); $consumer = new OAuthConsumer($CONSUMER_KEY, $CONSUMER_SECRET, NULL); // Create an Atom entry $contactAtom = new DOMDocument(); // $contactAtom = null; $request = OAuthRequest::from_consumer_and_token($consumer, NULL, $type, $base_feed, $params); // Sign the constructed OAuth request using HMAC-SHA1 $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL); // scope=https://docs.google.com/feeds/%20http://spreadsheets.google.com/feeds/%20https://docs.googleusercontent.com/ // Make signed OAuth request to the Contacts API server if (!is_null($params)) { $url = $base_feed . '?' . implode_assoc('=', '&', $params); } else { $url = $base_feed; } $header_request = $request->to_header(); $response = send_request($request->get_normalized_http_method(), $url, $header_request, $contactAtom, $postdata, $version, $content_type, $slug, $batch); return $response; }
/** * Generate a query string with the option to exclude key/value pairs * * @param array/String $exclude * @param array $arr * @param String $glue * @return String */ function query_string($exclude = array(), array $arr = NULL, $glue = '&') { $ret = ''; if (!is_array($exclude)) { $exclude = array((string) $exclude); } $exclude = array_lookup($exclude); if (!isset($arr)) { $arr = $_GET; } $get = array(); foreach ($arr as $key => $val) { if (!isset($exclude[$key])) { $get[$key] = $val; } } if (!empty($get)) { $ret = implode($glue, implode_assoc('=', $get)); } return $ret; }
function implode_assoc($inner_glue = "=", $outer_glue = "\n", $array = null, $keepOuterKey = false) { $output = array(); foreach ($array as $key => $item) { if (is_array($item)) { if ($keepOuterKey) { $output[] = $key; } // This is value is an array, go and do it again! $output[] = implode_assoc($inner_glue, $outer_glue, $item, $keepOuterKey); } else { $output[] = $key . $inner_glue . $item; } } return implode($outer_glue, $output); }
$error = ''; $focus = new $current_bean_type(); $focus->initRequiredFields($module); // SAVE MAPPING IF REQUESTED if (isset($_REQUEST['save_map']) && $_REQUEST['save_map'] == 'on' && isset($_REQUEST['save_map_as']) && $_REQUEST['save_map_as'] != '') { p("save map"); $serialized_mapping = ''; if ($has_header) { foreach ($col_pos_to_field as $pos => $field_name) { if (isset($firstrow[$pos]) && isset($field_name)) { $header_to_field[$firstrow[$pos]] = $field_name; } } $serialized_mapping = implode_assoc("=", "&", $header_to_field); } else { $serialized_mapping = implode_assoc("=", "&", $col_pos_to_field); } $mapping_file_name = $_REQUEST['save_map_as']; $mapping_file = new ImportMap(); $result = $mapping_file->save_map($current_user->id, $mapping_file_name, $_REQUEST['module'], $has_header, $serialized_mapping); $adb->println("Save map done"); $adb->println($result); } //save map - ends if (isset($_SESSION['totalrows']) && $_SESSION['totalrows'] != '') { $xrows = $_SESSION['totalrows']; } else { $xrows = $datarows; } if (isset($_SESSION['return_field_count'])) { $ret_field_count = $_SESSION['return_field_count'];
function perform() { // set display requirements $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Search Results', 'content' => 'content/questionSearchResults.php'); // The number of questions and page offset we want $count = grwd('count', 50); $page = grwd('page', 1); $result['count'] = $count; $result['page'] = $page; // don't lose the db! $db = $_REQUEST['db']; $userFinder = new UserFinder($db); $user = $userFinder->findById($_SESSION['userId']); $result['user'] = $user; // Generate a base URL for this search -- can't have page or count data // cos we're going to build pagination links from this $criteriaArray = $_GET; unset($criteriaArray['page']); unset($criteriaArray['count']); $advancedSearchString = implode_assoc('=', '&', $criteriaArray, true, true); $result['criteria_array'] =& $criteriaArray; $baseUrl = 'advancedSearch.do?' . $advancedSearchString; $result['advanced_search_string'] = $advancedSearchString; // gather request data $date1 = grwd('date1'); $date2 = grwd('date2'); $library_id_post = grwd('library_id') + 0; $location_id_post = grwd('location_id') + 0; $initials = grwd('initials'); $searchString = grwd('searchString'); $result['searchWords'] = $searchString; $questionFinder = new QuestionFinder($db); $startDate = array('database_field' => 'questions.question_date', 'relation' => '>=', 'value' => $date1, 'type' => 'DATE'); $endDate = array('database_field' => 'questions.question_date', 'relation' => '<=', 'value' => $date2, 'type' => 'DATE'); $library_id = array('database_field' => 'questions.library_id', 'relation' => '=', 'value' => $library_id_post, 'type' => 'INT'); $location_id = array('database_field' => 'questions.location_id', 'relation' => '=', 'value' => $location_id_post, 'type' => 'INT'); $initials = array('database_field' => 'questions.initials', 'relation' => 'LIKE', 'value' => $initials, 'type' => 'TEXT'); $searchCriteria = array('database_field' => array('question', 'answer'), 'relation' => 'fulltext', 'value' => $searchString, 'type' => 'FULLTEXT'); // pull together all of the search criteria $criteria = array('start_date' => $startDate, 'end_date' => $endDate, 'library_id' => $library_id, 'location_id' => $location_id, 'initials' => $initials, 'search_criteria' => $searchCriteria); $sql = ""; $param = array(); foreach ($criteria as $value) { if (!$value["value"]) { continue; } if (count($param) != 0) { $sql .= ' AND '; } if ($value["type"] == "FULLTEXT") { // Track if this is the first fulltext in group $orNeeded = false; $sql .= ' ( '; foreach ($value["database_field"] as $field) { if ($orNeeded) { $sql .= " OR "; } $sql .= 'MATCH(' . $field . ") AGAINST(? IN BOOLEAN MODE)"; $param[] = mySqlFulltextString($value["value"]); $orNeeded = true; } $sql .= ' ) '; } else { if ($value['type'] == "DATE") { // Make dates sane; the only part of this that's special $sDate = makeDateSane($value['value']); $sDate = date('Y-m-d', strtotime($sDate)); $sql .= $value["database_field"] . ' ' . $value["relation"] . ' ? '; $param[] = $sDate; } else { $sql .= $value["database_field"] . ' ' . $value["relation"] . ' ? '; $param[] = $value["value"]; } } } $questionFinder = new QuestionFinder($db); $qList =& $questionFinder->getPagedList($count, $page, $sql, $param); $result['questionList'] =& $qList['list']; $result['list_meta'] = $qList['meta']; $libraryFinder = new LibraryFinder($db); $searchLibName = $libraryFinder->getLibraryName($library_id_post); if ($library_id_post == 0) { $searchLibName = "All Libraries"; } if (isset($location_id_post)) { $locationFinder = new LocationFinder($db); $searchLocName = $locationFinder->getLocation($location_id_post); } $result['origin'] = $baseUrl . "&page={$page}&count={$count}"; $result['base_url'] = $baseUrl; $result['date1'] = $date1; $result['date2'] = $date2; $result['library_id'] = $library_id; $result['library_name'] = $searchLibName; $result['search_library_id'] = $library_id_post; $result['location_id'] = $location_id; $result['location_name'] = $searchLocName; $result['criteria'] = $criteria; // $result['sql'] = $sql; return $result; }
/** * Join array elements as key=value with a glue string. * This is the reverse of split_set. * * @param string $glue * @param array $array * @param string $format Format for each pair in sprintf format: key, value, full key. Can be array(format num, format assoc). * @param string $group_prefix Use %s for key * @param string $group_suffix * @param string $quote Quote values (default is where needed) * @param string $key_prefix * @return string */ function join_set($glue, $array, $format = array('%2$s', '%3$s=%2$s'), $group_prefix = '', $group_suffix = '', $quote = null, $key_prefix = null) { if (empty($array)) { return ''; } if (is_array($format)) { list($format_num, $format_assoc) = $format; } else { $format_num = $format_assoc = $format; } $result = ""; foreach ($array as $key => $value) { if (is_array($value)) { $result .= sprintf($group_prefix, $key) . implode_assoc($glue, $value, $format_assoc, $group_prefix, $group_suffix, $quote, $key_prefix . $key . '.') . $group_suffix . $glue; } else { if ($quote || !isset($quote) && (strpos($value, $glue) !== false || strpos($value, '=') !== false)) { $value = '"' . addcslashes($value, '"') . '"'; } $result .= sprintf(is_int($key) ? $format_num : $format_assoc, $key, $value, $key_prefix . $key) . $glue; } } return substr($result, 0, -1 * strlen($glue)); }
/** * Setup configuration form * @author Ivan Lucas * @retval string HTML */ function setup_configure() { global $SETUP, $CFGVAR, $CONFIG, $configfiles, $config_filename, $cfg_file_exists; global $cfg_file_writable, $numconfigfiles; $html = ''; if ($cfg_file_exists and $_REQUEST['configfile'] != 'new') { if ($_SESSION['new']) { if ($numconfigfiles < 2) { $html .= "<h4>Found an existing config file <var>{$config_filename}</var></h4>"; } else { $html .= "<p class='error'>Found more than one existing config file</p>"; if ($cfg_file_writable) { $html .= "<ul>"; foreach ($configfiles as $conf_filename) { $html .= "<li><var>{$conf_filename}</var></li>"; } $html .= "</ul>"; } } } //$html .= "<p>Since you already have a config file we assume you are upgrading or reconfiguring, if this is not the case please delete the existing config file.</p>"; if ($cfg_file_writable) { $html .= "<p class='error'>Important: The file permissions on the configuration file "; $html .= "allow it to be modified, we recommend you make this file read-only once SiT! is configured."; $html .= "</p>"; } else { $html .= "<p><a href='setup.php?action=reconfigure&configfile=new' >Create a new config file</a>.</p>"; } } else { $html .= "<h2>New Configuration</h2><p>Please complete this form to create a new configuration file for SiT!</p>"; } if ($cfg_file_writable or $_SESSION['new'] === 1 or $cfg_file_exists == FALSE or $_REQUEST['configfile'] == 'new') { $html .= "\n<form action='setup.php' method='post'>\n"; if ($_REQUEST['config'] == 'advanced') { $html .= "<input type='hidden' name='config' value='advanced' />\n"; foreach ($CFGVAR as $setupvar => $setupval) { $SETUP[] = $setupvar; } } $c = 1; foreach ($SETUP as $setupvar) { $html .= "<div class='configvar{$c}'>"; if ($CFGVAR[$setupvar]['title'] != '') { $title = $CFGVAR[$setupvar]['title']; } else { $title = $setupvar; } $html .= "<h4>{$title}</h4>"; if ($CFGVAR[$setupvar]['help'] != '') { $html .= "<p class='helptip'>{$CFGVAR[$setupvar]['help']}</p>\n"; } $html .= "<var>\$CONFIG['{$setupvar}']</var> = "; $value = ''; if (!$cfg_file_exists or $cfg_file_exists and $cfg_file_writable) { $value = $CONFIG[$setupvar]; if (is_bool($value)) { if ($value == TRUE) { $value = 'TRUE'; } else { $value = 'FALSE'; } } elseif (is_array($value)) { if (is_assoc($value)) { $value = "array(" . implode_assoc('=>', ',', $value) . ")"; } else { $value = "array(" . implode(',', $value) . ")"; } } if ($setupvar == 'db_password' and $_REQUEST['action'] != 'reconfigure') { $value = ''; } } if (!$cfg_file_exists or $_REQUEST['configfile'] == 'new') { // Dynamic defaults // application_fspath was removed, leaving this code just-in-case // DEPRECATED - remove for >= 3.50 if ($setupvar == 'application_fspath') { $value = str_replace('htdocs' . DIRECTORY_SEPARATOR, '', dirname(__FILE__) . DIRECTORY_SEPARATOR); } if ($setupvar == 'application_webpath') { $value = dirname(strip_tags($_SERVER['PHP_SELF'])); if ($value == '/' or $value == '\\') { $value = '/'; } else { $value = $value . '/'; } } } switch ($CFGVAR[$setupvar]['type']) { case 'select': $html .= "<select name='{$setupvar}'>"; if (empty($CFGVAR[$setupvar]['options'])) { $CFGVAR[$setupvar]['options'] = "TRUE|FALSE"; } $options = explode('|', $CFGVAR[$setupvar]['options']); foreach ($options as $option) { $html .= "<option value=\"{$option}\""; if ($option == $value) { $html .= " selected='selected'"; } $html .= ">{$option}</option>\n"; } $html .= "</select>"; break; case 'percent': $html .= "<select name='{$setupvar}'>"; for ($i = 0; $i <= 100; $i++) { $html .= "<option value=\"{$i}\""; if ($i == $value) { $html .= " selected='selected'"; } $html .= ">{$i}</option>\n"; } $html .= "</select>"; break; case 'text': default: if (strlen($CONFIG[$setupvar]) < 65) { $html .= "<input type='text' name='{$setupvar}' size='60' value=\"{$value}\" />"; } else { $html .= "<textarea name='{$setupvar}' cols='60' rows='10'>{$value}</textarea>"; } } if ($setupvar == 'db_password' and $_REQUEST['action'] != 'reconfigure' and $value != '') { $html .= "<p class='info'>The current password setting is not shown</p>"; } $html .= "</div>"; $html .= "<br />\n"; if ($c == 1) { $c == 2; } else { $c = 1; } } $html .= "<input type='hidden' name='action' value='save_config' />"; $html .= "<br /><input type='submit' name='submit' value='Save Configuration' />"; $html .= "</form>\n"; } return $html; }
function html_style_image($class, $title = null, $id = null, array $css = array()) { $classes = array('image', $class); $html = sprintf('<span class="%s"', implode(' ', $classes)); if (count($css) > 0) { $html .= sprintf('style="%s"', implode_assoc($css, ':', ';')); } if (isset($title) && is_string($title)) { $html .= sprintf(' title="%s"', htmlentities_array($title)); } if (isset($id) && is_string($id)) { $html .= sprintf(' id="%s"', htmlentities_array($id)); } return $html . '></span>'; }
function parse_array_to_css($css_rules_array) { $css_file_contents = ''; foreach ($css_rules_array as $selector => $rules_set) { ksort($rules_set); $selector = implode(",\n", array_map('trim', explode(',', $selector))); $css_file_contents .= sprintf("%s {\n %s;\n}\n\n", $selector, implode_assoc($rules_set, ': ', ";\n ")); } return trim($css_file_contents); }
/** * Constructor, allows subauth requests using the response from an initial * AuthSubRequest or with the subauth long-term token. Note that constructing * this object without a valid token will cause an exception to be thrown. * * @param string $sessiontoken A long-term subauth session token * @param string $authtoken A one-time auth token wich is used to upgrade to session token * @param mixed @options Options to pass to the base curl object */ public function __construct($sessiontoken = '', $authtoken = '', $options = array()) { // $returnurl = new moodle_url('/repository/repository_callback.php', // array('callback' => 'yes', 'repo_id' =>$options['repo_id'])); // unset($options['repo_id']); // set up variables and parameters $type = 'GET'; $url = get_morsle_url($options); // $url = str_replace('default',urlencode($options['xoauth_requestor_id']), $url); // if (array_key_exists('path', $options)) { // unset($options['path']); // } foreach ($options as $key => $param) { if ($key === 'q') { $param = urlencode($param); } $params[$key] = $param; } $consumer = new OAuthConsumer($CONSUMER_KEY, $CONSUMER_SECRET, NULL); // Create an Atom entry // $contactAtom = new DOMDocument(); // $contactAtom = null; $request = OAuthRequest::from_consumer_and_token($consumer, NULL, $type, $url, $params); // Sign the constructed OAuth request using HMAC-SHA1 $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL); if (!is_null($params)) { $url = $url . '?' . implode_assoc('=', '&', $params); // } else { // $url = $url; } $header_request = $request->to_header(); $this->setHeader($header_request); return $header_request; // at what point do we actually make the get request from Google -- work backward from there and integrate send_rquest // $response = send_request($request->get_normalized_http_method(), $url, $header_request, $contactAtom, $postdata, $version, $content_type, $slug, $batch); // return $response; }
function filter($filter, $value, $filters = '') { parse_str($filters, $filters); // resetting dependencies // if ('type'==$filter or 'commercial'==$filter) { // $filters = reset_dependencies($filters); // } $type = detect_filter_type($value); if ('check' == $type) { $is_on = array_key_exists($filter, $filters); unset($filters[$filter]); $filter_query = implode_assoc('&', $filters); if ($is_on) { return $filter_query; } else { return $filter_query . "&{$filter}={$value}"; } } else { if ('list' == $type) { // $filters[$filter] = [asus;acer;lenovo;toshiba;sony]; // $value = [asus] // $result = [acer;lenovo;toshiba;sony] $value = trim($value, '[]'); $old_filter = trim($filters[$filter], '[]'); $items = explode(';', $old_filter); $is_on = in_array($value, $items); $clear_filter = array_values(array_diff($items, [$value])); $clear_filter_str = implode(';', $clear_filter); unset($filters[$filter]); $filter_query = implode_assoc('&', $filters); if ($is_on) { return $filter_query . "&{$filter}=[{$clear_filter_str}]"; } else { return $filter_query . "&{$filter}=[{$clear_filter_str};{$value}]"; } } else { if ('range' == $type) { unset($filters[$filter]); $filter_query = implode_assoc('&', $filters); return $filter_query . "&{$filter}={$value}"; } else { if ('type' == $type) { $is_on = (array_key_exists($filter, $filters) and $filters[$filter] == $value); // important parenthesis unset($filters[$filter]); $filter_query = implode_assoc('&', $filters); if ($is_on) { return $filter_query; } else { return $filter_query . "&{$filter}={$value}"; } } } } } }
<?php require_once 'src/OAuth.php'; // Establish an OAuth consumer based on our admin 'credentials' $CONSUMER_KEY = 'yourdomain.com'; $CONSUMER_SECRET = 'YOUR_CONSUMER_SECRET'; $consumer = new OAuthConsumer($CONSUMER_KEY, $CONSUMER_SECRET, NULL); // Setup OAuth request based our previous credentials and query $user = '******'; $base_feed = 'http://www.google.com/m8/feeds/contacts/default/full/'; $params = array('max-results' => 10, 'xoauth_requestor_id' => $user); $request = OAuthRequest::from_consumer_and_token($consumer, NULL, 'GET', $base_feed, $params); // Sign the constructed OAuth request using HMAC-SHA1 $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL); // Make signed OAuth request to the Contacts API server $url = $base_feed . '?' . implode_assoc('=', '&', $params); echo send_request($request->get_normalized_http_method(), $url, $request->to_header()); /** * Makes an HTTP request to the specified URL * @param string $http_method The HTTP method (GET, POST, PUT, DELETE) * @param string $url Full URL of the resource to access * @param string $auth_header (optional) Authorization header * @param string $postData (optional) POST/PUT request body * @return string Response body from the server */ function send_request($http_method, $url, $auth_header = null, $postData = null) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
/** * HTML for a config variable input box * @author Ivan Lucas * @param string $setupvar The setup variable key name * @param bool $showvarnames Whether to display the config variable name * @returns string HTML */ function cfgVarInput($setupvar, $showvarnames = FALSE) { global $CONFIG, $CFGVAR; if ($CFGVAR[$setupvar]['type'] == 'languageselect' or $CFGVAR[$setupvar]['type'] == 'languagemultiselect') { $available_languages = available_languages(); } $html .= "<div class='configvar'>"; if ($CFGVAR[$setupvar]['title'] != '') { $title = $CFGVAR[$setupvar]['title']; } else { $title = $setupvar; } $html .= "<h4>{$title}</h4>"; if ($CFGVAR[$setupvar]['help'] != '') { $html .= "<p class='helptip'>{$CFGVAR[$setupvar]['help']}</p>\n"; } $value = ''; if (!$cfg_file_exists or $cfg_file_exists and $cfg_file_writable) { $value = $CONFIG[$setupvar]; if (is_bool($value)) { if ($value == TRUE) { $value = 'TRUE'; } else { $value = 'FALSE'; } } elseif (is_array($value)) { if (is_assoc($value)) { $value = "array(" . implode_assoc('=>', ',', $value) . ")"; } else { $value = "array(" . implode(',', $value) . ")"; } } if ($setupvar == 'db_password' and $_REQUEST['action'] != 'reconfigure') { $value = ''; } } $value = stripslashes($value); switch ($CFGVAR[$setupvar]['type']) { case 'select': $html .= "<select name='{$setupvar}' id='{$setupvar}'>"; if (empty($CFGVAR[$setupvar]['options'])) { $CFGVAR[$setupvar]['options'] = "TRUE|FALSE"; } $options = explode('|', $CFGVAR[$setupvar]['options']); foreach ($options as $option) { $html .= "<option value=\"{$option}\""; if ($option == $value) { $html .= " selected='selected'"; } $html .= ">{$option}</option>\n"; } $html .= "</select>"; break; case 'percent': $html .= "<select name='{$setupvar}' id='{$setupvar}'>"; for ($i = 0; $i <= 100; $i++) { $html .= "<option value=\"{$i}\""; if ($i == $value) { $html .= " selected='selected'"; } $html .= ">{$i}</option>\n"; } $html .= "</select>%"; break; case 'interfacestyleselect': $html .= interfacestyle_drop_down($setupvar, $value); break; case 'languageselect': if (empty($value)) { $value = $_SESSION['lang']; } $html .= array_drop_down($available_languages, $setupvar, $value, '', TRUE); break; case 'languagemultiselect': if (empty($value)) { foreach ($available_languages as $code => $lang) { $value[] = $code; } $checked = TRUE; } else { $checked = FALSE; $replace = array('array(', ')', "'"); $value = str_replace($replace, '', $value); $value = explode(',', $value); } $html .= array_drop_down($available_languages, $setupvar, $value, '', TRUE, TRUE); $attributes = "onchange=\"toggle_multiselect('{$setupvar}[]')\""; $html .= "<label>" . html_checkbox($setupvar . 'checkbox', $checked, ""); $html .= $GLOBALS['strAll'] . "</label>"; break; case 'slaselect': $html .= serviceleveltag_drop_down($setupvar, $value, TRUE); break; case 'userselect': $html .= user_drop_down($setupvar, $value, FALSE, FALSE, '', TRUE); break; case 'siteselect': $html .= site_drop_down($setupvar, $value, FALSE); break; case 'userstatusselect': $html .= userstatus_drop_down($setupvar, $value); break; case 'roleselect': $html .= role_drop_down($setupvar, $value); break; case 'number': $html .= "<input type='text' name='{$setupvar}' id='{$setupvar}' size='7' value=\"{$value}\" />"; break; case '1darray': $replace = array('array(', ')', "'"); $value = str_replace($replace, '', $value); $html .= "<input type='text' name='{$setupvar}' id='{$setupvar}' size='60' value=\"{$value}\" />"; break; case '2darray': $replace = array('array(', ')', "'", '\\r', '\\n'); $value = str_replace($replace, '', $value); $value = str_replace(',', "\n", $value); $html .= "<textarea name='{$setupvar}' id='{$setupvar}' cols='60' rows='10'>{$value}</textarea>"; break; case 'password': $html .= "<input type='password' id='cfg{$setupvar}' name='{$setupvar}' size='16' value=\"{$value}\" /> " . password_reveal_link("cfg{$setupvar}"); break; case 'ldappassword': $html .= "<input type='password' id='cfg{$setupvar}' name='{$setupvar}' size='16' value=\"{$value}\" /> " . password_reveal_link("cfg{$setupvar}"); $html .= " <a href='javascript:void(0);' onclick=\"checkLDAPDetails('status{$setupvar}');\">{$GLOBALS['strCheckLDAPDetails']}</a>"; break; case 'text': default: if (strlen($CONFIG[$setupvar]) < 65) { $html .= "<input type='text' name='{$setupvar}' id='{$setupvar}' size='60' value=\"{$value}\" />"; } else { $html .= "<textarea name='{$setupvar}' id='{$setupvar}' cols='60' rows='10'>{$value}</textarea>"; } } if (!empty($CFGVAR[$setupvar]['unit'])) { $html .= " {$CFGVAR[$setupvar]['unit']}"; } if (!empty($CFGVAR[$setupvar]['helplink'])) { $html .= ' ' . help_link($CFGVAR[$setupvar]['helplink']); } if ($setupvar == 'db_password' and $_REQUEST['action'] != 'reconfigure' and $value != '') { $html .= "<p class='info'>The current password setting is not shown</p>"; } if ($showvarnames) { $html .= "<br />(<var>\$CONFIG['{$setupvar}']</var>)"; } if ($CFGVAR[$setupvar]['statusfield'] == 'TRUE') { $html .= "<div id='status{$setupvar}'></div>"; } $html .= "</div>"; $html .= "<br />\n"; if ($c == 1) { $c == 2; } else { $c = 1; } return $html; }
$httpClient->setHeaders($req->to_header()); $docsService = new Zend_Gdata_Docs($httpClient); $query = $feedUri . '?' . implode_assoc('=', '&', $params); $feed = $docsService->getDocumentListFeed($query); $data['docs']['html'] = listEntries($feed); $data['docs']['xml'] = $feed->saveXML(); // =========================================================================== // Query the Spreadsheets API ================================================ $feedUri = 'http://spreadsheets.google.com/feeds/spreadsheets/private/full'; $params = array('max-results' => 50); $req = OAuthRequest::from_consumer_and_token($consumer, $access_token, 'GET', $feedUri, $params); $req->sign_request($sig_method, $consumer, $access_token); // Note: the Authorization header changes with each request $httpClient->setHeaders($req->to_header()); $spreadsheetsService = new Zend_Gdata_Spreadsheets($httpClient); $query = $feedUri . '?' . implode_assoc('=', '&', $params); $feed = $spreadsheetsService->getSpreadsheetFeed($query); $data['spreadsheets']['html'] = listEntries($feed); $data['spreadsheets']['xml'] = $feed->saveXML(); // =========================================================================== // Query Google's Portable Contacts API ====================================== $feedUri = 'http://www-opensocial.googleusercontent.com/api/people/@me/@all'; $req = OAuthRequest::from_consumer_and_token($consumer, $access_token, 'GET', $feedUri, NULL); $req->sign_request($sig_method, $consumer, $access_token); // Portable Contacts isn't GData, but we can use send_signed_request() from // common.inc.php to make an authenticated request. $data['poco'] = send_signed_request($req->get_normalized_http_method(), $feedUri, $req->to_header(), NULL, false); // =========================================================================== } switch (@$_REQUEST['openid_mode']) { case 'checkid_setup':
/** * Store AUTH info to session data. */ protected function storeInfo() { $this->info = null; if ($this->user) { $this->info['uid'] = $this->user->getId(); $this->info['checksum'] = $this->checksum(); } $matches = null; if (is_string($this->store)) { $this->store = extract_dsn($this->store); } switch ($this->store['driver']) { case 'none': break; case 'session': session_start(); $_SESSION['AUTH'] = $this->info; break; case 'cookie': $cookie_params = $this->store + session_get_cookie_params(); if (!isset($this->info)) { $this->info = array(); foreach (array_keys($_COOKIE) as $key) { if (!preg_match('/^AUTH_(.*)$/i', $key, $matches)) { continue; } setcookie($key, null, 1, $cookie_params['path'], $cookie_params['domain'], $cookie_params['secure'], $cookie_params['httponly']); unset($_COOKIE[$key]); } } else { foreach (array_combine_assoc($this->info, 'AUTH', '_') as $key => $value) { setcookie($key, $value, ($cookie_params['lifetime'] <= 1 ? 0 : time()) + $cookie_params['lifetime'], $cookie_params['path'], $cookie_params['domain'], $cookie_params['secure'], $cookie_params['httponly']); $_COOKIE[$key] = $value; } } break; case 'request': HTTP::addUrlRewriteVar('AUTH', $this->info); $_REQUEST['AUTH'] = $this->info; break; case 'env': putenv('AUTH=' . $this->info ? escapeshellarg(implode_assoc(';', $this->info)) : null); break; default: throw new Exception("Invalid option '{$this->store['driver']}' specified for storing info."); } }