<?php
$db = $injector->getInstance('Horde_Db_Adapter');
+$q_cache_id = Horde_Session::DATA . ':sql_query_cache;array';
+$q_cache = $session[$q_cache_id];
if (Horde_Util::getFormData('list-tables')) {
$description = 'LIST TABLES';
$command = null;
} elseif ($command = trim(Horde_Util::getFormData('sql'))) {
// Keep a cache of prior queries for convenience.
- if (!isset($_SESSION['_sql_query_cache'])) {
- $_SESSION['_sql_query_cache'] = array();
- }
- if (($key = array_search($command, $_SESSION['_sql_query_cache'])) !== false) {
- unset($_SESSION['_sql_query_cache'][$key]);
- }
- array_unshift($_SESSION['_sql_query_cache'], $command);
- while (count($_SESSION['_sql_query_cache']) > 20) {
- array_pop($_SESSION['_sql_query_cache']);
+ if (($key = array_search($command, $q_cache)) !== false) {
+ unset($q_cache[$key]);
}
+ $q_cache[] = $command;
+ $q_cache = array_slice($q_cache, -20);
+ $session[$q_cache_id] = $q_cache;
// Parse out the query results.
$result = $db->execute(Horde_String::convertCharset($command, 'UTF-8', $conf['sql']['charset']));
}
?>
-<?php if (isset($_SESSION['_sql_query_cache']) &&
- count($_SESSION['_sql_query_cache'])): ?>
+<?php if (count($q_cache)): ?>
<label for="query_cache" class="hidden"><?php echo ("Query cache") ?></label>
<select id="query_cache" name="query_cache" onchange="document.sqlshell.sql.value = document.sqlshell.query_cache[document.sqlshell.query_cache.selectedIndex].value;">
- <?php foreach ($_SESSION['_sql_query_cache'] as $query): ?>
+ <?php foreach ($q_cache as $query): ?>
<option value="<?php echo htmlspecialchars($query) ?>"><?php echo htmlspecialchars($query) ?></option>
<?php endforeach; ?>
</select>
// // Example #2: Set the fullname from LDAP information. In this
// // example we look if a Spanish name exists and return this or the
// // standard 'cn' entry if not.
-// $ldapServer = 'ldap.example.com';
+// $$dapServer = 'ldap.example.com';
// $ldapPort = '389';
// $searchBase = 'ou=people,o=example.com';
//
// : $userId;
// $entry['sn'] = $userId;
// $entry['objectclass'][0] = 'top';
-// $entry['objectclass'][1] = 'person';
+// $ $y['objectclass'][1] = 'person';
// $entry['objectclass'][2] = 'qmailuser';
// $entry['objectclass'][3] = 'CourierMailACcount';
// $entry['mailhost'] = 'mail.example.com';
// $searchResult = @ldap_search($ds, $searchBase, $userAttr . '=' . $userId, array($groupAttr), 0, 1, 5);
// if ($information = @ldap_get_entries($ds, $searchResult)) {
// // Make pattern case-insensitive
-// $pattern = '/' . $groupdn . '/i';
+// $pattern = '/' . $$roupdn . '/i';
// foreach ($information[0][$groupAttr] as $group) {
// if (preg_match($pattern, $group)) {
// $ret = true;
// {
// // Example #1: Send a notification message to the web server
// // administrator's e-mail address.
-// $headers = array(
+// $ $aders = array(
// 'To' => $_SERVER['SERVER_ADMIN'],
// 'From' => $_SERVER['SERVER_ADMIN'],
// 'Subject' => 'New ' . $GLOBALS['registry']->get('name', 'horde') . ' Signup'
// public function perms_denied($permission)
// {
// // Example #1: Provide link to upgrade script.
-// $app = (($pos = strpos($permission, ':')) === false)
+// $app = (($pos = strpos($? $mission, ':')) === false)
// ? $permission
// : substr($permission, 0, $pos);
//
*/
// public function share_init($share_obj, $app)
// {
+// global $cfgSources, $prefs, $session;
+//
// // TODO: Move to turba?
// if (($app == 'turba') &&
-// (!empty($GLOBALS['cfgSources']['imsp']['use_shares']))) {
+// (!empty($cfgSources['imsp']['use_shares']))) {
// // Only do this once per session or when this session variable
// // is purposely unset.
-// if (!empty($_SESSION['imsp_synched'])) {
+// if ($session['horde:imsp_synched']) {
// return;
// }
//
-// $results = Net_IMSP_Utils::synchShares($share_obj, $GLOBALS['cfgSources']['imsp']);
+// $results = Net_IMSP_Utils::synchShares($share_obj, $cfgSources['imsp']);
// if (!$results instanceof PEAR_Error) {
-// $_SESSION['imsp_synched'] = true;
+// $session['horde:imsp_synched'] = true;
//
// // Now deal with adding or removing address books from prefs.
// // FIXME: Updating prefs seems to hang the server. Narrowed
// // call a hook. (Commenting out the callHook call fixes). Can
// // anyone verify this on their install?
// $dirty = false;
-// $abooks = $GLOBALS['prefs']->getValue('addressbooks');
+// $abooks = $prefs->getValue('addressbooks');
// $abooks = empty($abooks)
// ? array()
-// : explode("\n", $GLOBALS['prefs']->getValue('addressbooks'));
+// : explode("\n", $prefs->getValue('addressbooks'));
//
// if (count($results['removed'] > 0)) {
// foreach ($results['removed'] as $sharename) {
// }
//
// if ($dirty) {
-// $result = $GLOBALS['prefs']->setValue('addressbooks', implode("\n", $abooks));
+// $result = $prefs->setValue('addressbooks', implode("\n", $abooks));
// }
//
// // We have to save the connection info for the imsp server
// // since the share_modify hook will not occur from within
// // turba's context.
-// $_SESSION['imsp_config'] = $GLOBALS['cfgSources']['imsp']['params'];
+// $session['horde:imsp_config'] = $cfgSources['imsp']['params'];
// }
// }
// }
*/
// public function share_modify($share)
// {
+// global $injector, $session, $share;
+//
// $params = unserialize($share->get('params'));
-// if (is_array($params) && !empty($params['source']) &&
-// $params['source'] = 'imsp' &&
-// !empty($_SESSION['imsp_config'])) {
+// if (is_array($params) &&
+// !empty($params['source']) &&
+// ($params['source'] == 'imsp') &&
+// $session['horde:imsp_config']) {
// // Ensure we don't try to change ownership.
// $params = @unserialize($share->get('params'));
// $bookName = $params['name'];
// if (strpos($bookName, $share->get('owner')) !== 0) {
-// $err = new Horde_Exception('Changing ownership of IMSP address books is not supported.');
-// $GLOBALS['notification']->push($err);
-// throw $err;
+// throw new Horde_Exception('Changing ownership of IMSP address books is not supported.');
// }
-
+//
// // Update the ACLS
-// $perms = $GLOBALS['share']->getPermission();
-// $users = $GLOBALS['injector']->getInstance('Horde_Perms')->getUserPermissions();
+// $perms = $share->getPermission();
+// $users = $injector->getInstance('Horde_Perms')->getUserPermissions();
// foreach ($users as $user => $perm) {
// $acl = Net_IMSP_Utils::permsToACL($perm);
-// $result = Net_IMSP_Utils::setACL($_SESSION['imsp_config'], $bookName, $user, $acl);
+// $result = Net_IMSP_Utils::setACL($session['horde:imsp_config'], $bookName, $user, $acl);
// }
// }
// }
/* No requested action, check to see if we have a valid token */
if (!empty($auth_token)) {
$profile = Horde_Serialize::unserialize($twitter->account->verifyCredentials(), Horde_Serialize::JSON);
-} elseif (!empty($_SESSION['twitter_request_secret'])) {
+} elseif ($r_secret = $session->retrieve('twitter_request_secret'])) {
/* No existing auth token, maybe we are in the process of getting it? */
try {
- $auth_token = $twitter->auth->getAccessToken($GLOBALS['injector']->getInstance('Horde_Controller_Request'), $_SESSION['twitter_request_secret']);
+ $auth_token = $twitter->auth->getAccessToken($GLOBALS['injector']->getInstance('Horde_Controller_Request'), $r_secret);
} catch (Horde_Service_Twitter_Exception $e) {
echo '<div class="fberrorbox">' . sprintf(_("Error connecting to Twitter: %s Details have been logged for the administrator."), $e->getMessage()) . '</div>';
echo '</form>';
require HORDE_TEMPLATES . '/common-footer.inc';
exit;
}
+
/* Clear the temporary request secret */
- $_SESSION['twitter_request_secret'] = '';
+ $session->purge('twitter_request_secret');
if ($auth_token === false || empty($auth_token)) {
// We had a request secret, but something went wrong. maybe navigated
// back here between requests?