/** * @todo Implement testSetCookie(). */ public function testSetCookie() { $this->assertFalse($this->object->setCookie('TEST_DEF_COOKIE', 'test_def_123', 'test_def_123')); //$this->assertTrue($this->object->setCookie('TEST_CONFIG_COOKIE', 'test_val_123', null, 3600)); //$this->assertTrue($this->object->setCookie('TEST_CONFIG_COOKIE', '', 'default_val')); $_COOKIE['TEST_MANUAL_COOKIE'] = 'some_test_val'; //$this->assertTrue($this->object->setCookie('TEST_MANUAL_COOKIE', 'other', 'other')); }
/** * return complete font size selection form * * @static * * @return string html selectbox */ public static function getFontsizeForm() { return '<form name="form_fontsize_selection" id="form_fontsize_selection"' . ' method="get" action="index.php" class="disableAjax">' . "\n" . PMA_generate_common_hidden_inputs() . "\n" . PMA_Config::getFontsizeSelection() . "\n" . '</form>'; }
/** * return complete font size selection form * * @uses PMA_generate_common_hidden_inputs() * @uses PMA_Config::_getFontsizeSelection() * @static * @param string $current_size currently slected font size with unit * @return string html selectbox */ public static function getFontsizeForm() { return '<form name="form_fontsize_selection" id="form_fontsize_selection"' . ' method="post" action="index.php" target="_parent">' . "\n" . PMA_generate_common_hidden_inputs() . "\n" . PMA_Config::_getFontsizeSelection() . "\n" . '<noscript>' . "\n" . '<input type="submit" value="' . __('Go') . '" />' . "\n" . '</noscript>' . "\n" . '</form>'; }
/** * return complete font size selection form * * @static * * @return string html selectbox */ public static function getFontsizeForm() { return '<form name="form_fontsize_selection" id="form_fontsize_selection"' . ' method="post" action="index.php" target="_parent">' . "\n" . PMA_generate_common_hidden_inputs() . "\n" . PMA_Config::_getFontsizeSelection() . "\n" . '</form>'; }
echo ' <ul>'; // Displays language selection combo if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) { echo '<li id="li_select_lang" class="no_bullets">'; include_once 'libraries/display_select_lang.lib.php'; echo PMA_Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml(); echo '</li>'; } // ThemeManager if available if ($GLOBALS['cfg']['ThemeManager']) { echo '<li id="li_select_theme" class="no_bullets">'; echo PMA_Util::getImage('s_theme.png') . " " . $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox(); echo '</li>'; } echo '<li id="li_select_fontsize">'; echo PMA_Config::getFontsizeForm(); echo '</li>'; echo '</ul>'; // User preferences if ($server > 0) { echo '<ul>'; PMA_printListItem(PMA_Util::getImage('b_tblops.png') . " " . __('More settings'), 'li_user_preferences', 'prefs_manage.php' . $common_url_query, null, null, null, "no_bullets"); echo '</ul>'; } echo '</div>'; echo '</div>'; echo '<div id="main_pane_right">'; if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) { echo '<div class="group">'; echo '<h2>' . __('Database server') . '</h2>'; echo '<ul>' . "\n";
// (do not use & for parameters sent by header) header('Location: ' . (defined('PMA_SETUP') ? '../' : '') . 'error.php' . '?lang=' . urlencode($available_languages[$lang][2]) . '&dir=' . urlencode($text_dir) . '&type=' . urlencode($strError) . '&error=' . urlencode(sprintf($strCantLoad, 'session'))); exit; } elseif (ini_get('session.auto_start') == true && session_name() != 'phpMyAdmin') { $_SESSION = array(); if (isset($_COOKIE[session_name()])) { PMA_removeCookie(session_name()); } session_unset(); @session_destroy(); } // disable starting of sessions before all settings are done // does not work, besides how it is written in php manual //ini_set('session.auto_start', 0); // session cookie settings session_set_cookie_params(0, PMA_Config::getCookiePath() . '; HttpOnly', '', PMA_Config::isHttps()); // cookies are safer ini_set('session.use_cookies', true); // but not all user allow cookies ini_set('session.use_only_cookies', false); ini_set('session.use_trans_sid', true); ini_set('url_rewriter.tags', 'a=href,frame=src,input=src,form=fakeentry,fieldset='); //ini_set('arg_separator.output', '&'); // delete session/cookies when browser is closed ini_set('session.cookie_lifetime', 0); // warn but dont work with bug ini_set('session.bug_compat_42', false); ini_set('session.bug_compat_warn', true); // use more secure session ids (with PHP 5) if (version_compare(PHP_VERSION, '5.0.0', 'ge') && substr(PHP_OS, 0, 3) != 'WIN') { ini_set('session.hash_function', 1);
/** * sets cookie if value is different from current cokkie value, * or removes if value is equal to default * * @uses PMA_Config::isHttps() * @uses PMA_Config::getCookiePath() * @uses $_COOKIE * @uses PMA_removeCookie() * @uses setcookie() * @uses time() * @param string $cookie name of cookie to remove * @param mixed $value new cookie value * @param string $default default value * @param int $validity validity of cookie in seconds (default is one month) * @param bool $httponlt whether cookie is only for HTTP (and not for scripts) * @return boolean result of setcookie() */ function PMA_setCookie($cookie, $value, $default = null, $validity = null, $httponly = true) { if ($validity == null) { $validity = 2592000; } if (strlen($value) && null !== $default && $value === $default && isset($_COOKIE[$cookie])) { // remove cookie, default value is used return PMA_removeCookie($cookie); } if (!strlen($value) && isset($_COOKIE[$cookie])) { // remove cookie, value is empty return PMA_removeCookie($cookie); } if (!isset($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) { // set cookie with new value /* Calculate cookie validity */ if ($validity == 0) { $v = 0; } else { $v = time() + $validity; } return setcookie($cookie, $value, $v, PMA_Config::getCookiePath(), '', PMA_Config::isHttps(), $httponly); } // cookie has already $value as value return true; }
/** * Tests for rewriting URL to SSL variant * * @param string $original Original URL * @param string $expected Expected URL rewritten to SSL * * @dataProvider sslUris */ public function testSSLUri($original, $expected) { $this->object->set('PmaAbsoluteUri', $original); $this->assertEquals($expected, $this->object->getSSLUri()); }
* @category Setup * @package phpMyAdmin-setup * @author Michal Čihař <*****@*****.**> * @copyright 2006 Michal Čihař <*****@*****.**> * @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0 * @version $Id: setup.php 13149 2009-12-07 13:09:09Z nijel $ */ // Grab phpMyAdmin version and PMA_dl function define('PMA_MINIMUM_COMMON', TRUE); define('PMA_SETUP', TRUE); chdir('..'); require_once './libraries/common.inc.php'; // Grab configuration defaults // Do not use $PMA_Config, it interferes with the one in $_SESSION // on servers with register_globals enabled $PMA_Config_Setup = new PMA_Config(); // Script information $script_info = 'phpMyAdmin ' . $PMA_Config_Setup->get('PMA_VERSION') . ' setup script by Michal Čihař <*****@*****.**>'; $script_version = '$Id: setup.php 13149 2009-12-07 13:09:09Z nijel $'; // Grab action if (isset($_POST['action'])) { $action = $_POST['action']; } else { $action = ''; } // Grab wanted CRLF type if (isset($_POST['eoltype'])) { $_SESSION['eoltype'] = $_POST['eoltype']; } else { if (PMA_USR_OS == 'Win') { $_SESSION['eoltype'] = 'dos';
/** * Bootstrap for phpMyAdmin tests * * @package PhpMyAdmin-test */ // Let PHP complain about all errors error_reporting(E_ALL); // Adding phpMyAdmin sources to include path set_include_path(get_include_path() . PATH_SEPARATOR . dirname(realpath("../index.php"))); // Setting constants for testing define('PHPMYADMIN', 1); define('TESTSUITE', 1); define('PMA_MYSQL_INT_VERSION', 55000); require_once 'libraries/core.lib.php'; require_once 'libraries/Config.class.php'; $CFG = new PMA_Config(); define('PMA_VERSION', $CFG->get('PMA_VERSION')); unset($CFG); session_start(); // You can put some additional code that should run before tests here // Standard environment for tests $_SESSION[' PMA_token '] = 'token'; $GLOBALS['lang'] = 'en'; $GLOBALS['is_ajax_request'] = false; define('PMA_HAS_RUNKIT', function_exists('runkit_constant_redefine')); $GLOBALS['runkit_internal_override'] = ini_get('runkit.internal_override'); /** * Function to emulate headers() function by storing headers in GLOBAL array * * @param string $string header string * @param boolean $replace .
if (!@function_exists('session_name')) { PMA_fatalError('strCantLoad', 'session'); } elseif (ini_get('session.auto_start') == true && session_name() != 'phpMyAdmin') { // Do not delete the existing session, it might be used by other // applications; instead just close it. session_write_close(); } // disable starting of sessions before all settings are done // does not work, besides how it is written in php manual //ini_set('session.auto_start', 0); // session cookie settings session_set_cookie_params(0, PMA_Config::getCookiePath() . '; HttpOnly', '', PMA_Config::isHttps()); // cookies are safer (use @ini_set() in case this function is disabled) @ini_set('session.use_cookies', true); // but not all user allow cookies @ini_set('session.use_only_cookies', false); @ini_set('session.use_trans_sid', true); @ini_set('url_rewriter.tags', 'a=href,frame=src,input=src,form=fakeentry,fieldset='); //ini_set('arg_separator.output', '&'); // delete session/cookies when browser is closed @ini_set('session.cookie_lifetime', 0); // warn but dont work with bug
/** * sets cookie if value is different from current cokkie value, * or removes if value is equal to default * * @uses PMA_Config::isHttps() * @uses PMA_Config::getCookiePath() * @uses $_COOKIE * @uses PMA_removeCookie() * @uses setcookie() * @uses time() * @param string $cookie name of cookie to remove * @param mixed $value new cookie value * @param string $default default value * @return boolean result of setcookie() */ function PMA_setCookie($cookie, $value, $default = null) { if (strlen($value) && null !== $default && $value === $default && isset($_COOKIE[$cookie])) { // remove cookie, default value is used return PMA_removeCookie($cookie); } if (!strlen($value) && isset($_COOKIE[$cookie])) { // remove cookie, value is empty return PMA_removeCookie($cookie); } if (!isset($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) { // set cookie with new value return setcookie($cookie, $value, time() + 60 * 60 * 24 * 30, PMA_Config::getCookiePath(), '', PMA_Config::isHttps()); } // cookie has already $value as value return true; }
/** * sets cookie if value is different from current cokkie value, * or removes if value is equal to default * * @uses PMA_Config::isHttps() * @uses PMA_Config::getCookiePath() * @uses $_COOKIE * @uses PMA_removeCookie() * @uses setcookie() * @uses time() * @param string $cookie name of cookie to remove * @param mixed $value new cookie value * @param string $default default value * @param int $validity validity of cookie in seconds (default is one month) * @param bool $httponlt whether cookie is only for HTTP (and not for scripts) * @return boolean result of setcookie() */ function PMA_setCookie($cookie, $value, $default = null, $validity = null, $httponly = true) { if ($validity == null) { $validity = 2592000; } if (strlen($value) && null !== $default && $value === $default && isset($_COOKIE[$cookie])) { // remove cookie, default value is used return PMA_removeCookie($cookie); } if (!strlen($value) && isset($_COOKIE[$cookie])) { // remove cookie, value is empty return PMA_removeCookie($cookie); } if (!isset($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) { // set cookie with new value /* Calculate cookie validity */ if ($validity == 0) { $v = 0; } else { $v = time() + $validity; } /* Use native support for httponly cookies if available */ if (version_compare(PHP_VERSION, '5.2.0', 'ge')) { return setcookie($cookie, $value, $v, PMA_Config::getCookiePath(), '', PMA_Config::isHttps(), $httponly); } else { return setcookie($cookie, $value, $v, PMA_Config::getCookiePath() . ($httponly ? '; HttpOnly' : ''), '', PMA_Config::isHttps()); } } // cookie has already $value as value return true; }
/** * detect correct cookie path */ function checkCookiePath() { $this->set('cookie_path', PMA_Config::getCookiePath()); }
<?php /* $Id: setup.php,v 1.23.2.10.2.1 2006/08/01 14:01:37 lem9 Exp $ */ // vim: expandtab sw=4 ts=4 sts=4: // phpMyAdmin setup script by Michal Čihař <*****@*****.**> // Grab phpMyAdmin version and PMA_dl function define('PMA_MINIMUM_COMMON', TRUE); chdir('..'); require_once './libraries/common.lib.php'; // Grab configuration defaults $PMA_Config = new PMA_Config(); // Script information $script_info = 'phpMyAdmin ' . $PMA_Config->get('PMA_VERSION') . ' setup script by Michal Čihař <*****@*****.**>'; $script_version = '$Id: setup.php,v 1.23.2.10.2.1 2006/08/01 14:01:37 lem9 Exp $'; // Grab action if (isset($_POST['action'])) { $action = $_POST['action']; } else { $action = ''; } if (isset($_POST['configuration']) && $action != 'clear') { // Grab previous configuration, if it should not be cleared $configuration = unserialize($_POST['configuration']); } else { // Start with empty configuration $configuration = array(); } // We rely on Servers array to exist, so create it here if (!isset($configuration['Servers']) || !is_array($configuration['Servers'])) { $configuration['Servers'] = array(); }