This commit is contained in:
Marc Delisle
2009-05-18 14:20:25 +00:00
parent ce7be6d009
commit 644366eaf1
689 changed files with 198914 additions and 0 deletions

61
scripts/check_lang.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* This test script checks all the language files to ensure there is no errors
* inside and nothing is displayed on screen (eg no extra no blank line).
*
* @version $Id$
* @package phpMyAdmin-test
*/
/**
*
*/
$failed = array();
$passed = array();
// 1. Do check
$languageDirectory = dir('../lang');
while ($name = $languageDirectory->read()) {
if (strpos($name, '.inc.php')) {
// 1.1 Checks parse errors and extra blank line
include '../lang/' . $name;
header('X-Ping: pong');
// 1.1 Checks "^M"
$content = fread(fopen('../lang/' . $name, 'r'), filesize('../lang/' . $name));
if ($pos = strpos(' ' . $content, "\015")) {
$failed[] = $name;
} else {
$passed[] = $name;
}
} // end if
} // end while
$languageDirectory->close();
// 2. Checking results
$start = '';
$failed_cnt = count($failed);
sort($failed);
$passed_cnt = count($passed);
sort($passed);
echo ($failed_cnt + $passed_cnt) . ' language files were checked.<br /><br />' . "\n";
if ($failed_cnt) {
echo '&nbsp;&nbsp;1.&nbsp;' . $failed_cnt . ' contain(s) some "^M":<br />' . "\n";
for ($i = 0; $i < $failed_cnt; $i++) {
echo '&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;' . $failed[$i] . '<br />' . "\n";
} // end for
if ($passed_cnt) {
echo '<br />' . "\n";
echo '&nbsp;&nbsp;2.&nbsp;' . $passed_cnt . ' seems right:<br />' . "\n";
$start = '&nbsp;&nbsp;';
}
} // end if
if ($passed_cnt) {
if (!$failed_cnt) {
echo 'They all passed checkings:<br />' . "\n";
}
for ($i = 0; $i < $passed_cnt; $i++) {
echo $start . '&nbsp;&nbsp;-&nbsp;' . $passed[$i] . '<br />' . "\n";
} // end for
} // end if
?>

19
scripts/convertcfg.pl Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/perl
#
# $Id$
#
# Configuration converter
# Converts from old-style (Pre-2.3) configuration files to new format found in PMA-2.3
#
# Takes input from STDIN, sends output to STDOUT
#
# By Robin Johnson robbat2@users.sourceforge.net
# Many thanks to Patrick Lougheed pat@tfsb.org
#
while(<>)
{ s/\$cfg(\w+)/\$cfg\[\'$1\'\]/g;
print;
}

212
scripts/create-release.sh Executable file
View File

@@ -0,0 +1,212 @@
#!/bin/sh
#
# $Id$
# vim: expandtab sw=4 ts=4 sts=4:
#
KITS="all-languages english"
COMPRESSIONS="zip-7z tbz tgz 7z"
if [ $# = 0 ]
then
echo "Usages:"
echo " create-release.sh <version> [from_branch]"
echo " create-release.sh snapshot [sf]"
echo " (no spaces allowed!)"
echo ""
echo "Examples:"
echo " create-release.sh 2.9.0-rc1 branches/QA_2_9"
echo " create-release.sh 2.9.0 tags/RELEASE_2_9_0"
exit 65
fi
branch='trunk'
if [ "$1" = "snapshot" ] ; then
mode="snapshot"
date_snapshot=`date +%Y%m%d-%H%M%S`
target=$date_snapshot
else
if [ "$#" -ge 2 ] ; then
branch="$2"
fi
target="$1"
cat <<END
Please ensure you have:
1. incremented rc count or version in subversion :
- in libraries/Config.class.php PMA_Config::__constructor() the line
" \$this->set( 'PMA_VERSION', '$1' ); "
- in Documentation.html the 2 lines
" <title>phpMyAdmin $1 - Documentation</title> "
" <h1>phpMyAdmin $1 Documentation</h1> "
- in translators.html
- in README
2. checked that all language files are valid (use
the "./scripts/check_lang.php" script to do it).
Continue (y/n)?
END
read do_release
if [ "$do_release" != 'y' ]; then
exit
fi
fi
if [ "$mode" = "snapshot" -a "$2" = "sf" ] ; then
# Goto project dir
cd /home/groups/p/ph/phpmyadmin/htdocs
# Keep one previous version of the cvs directory
if [ -e svn-prev ] ; then
rm -rf svn-prev
fi
mv svn svn-prev
fi
# Do SVNcheckout
mkdir -p ./svn
cd svn
echo "Exporting repository from subversion"
svn export -q https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/$branch/phpMyAdmin
if [ $? -ne 0 ] ; then
echo "Subversion checkout failed, bailing out"
exit 2
fi
# Cleanup release dir
LC_ALL=C date -u > phpMyAdmin/RELEASE-DATE-${target}
# Building Documentation.txt
LC_ALL=C w3m -dump phpMyAdmin/Documentation.html > phpMyAdmin/Documentation.txt
# Remove test directory from package to avoid Path disclosure messages
# if someone runs /test/wui.php and there are test failures
rm -rf phpMyAdmin/test
# Renaming directory
mv phpMyAdmin phpMyAdmin-$target
# Prepare all kits
for kit in $KITS ; do
# Copy all files
name=phpMyAdmin-$target-$kit
cp -r phpMyAdmin-$target $name
# Cleanup translations
cd phpMyAdmin-$target-$kit
scripts/lang-cleanup.sh $kit
cd ..
# Prepare distributions
for comp in $COMPRESSIONS ; do
case $comp in
tbz|tgz)
echo "Creating $name.tar"
tar cf $name.tar $name
if [ $comp = tbz ] ; then
echo "Creating $name.tar.bz2"
bzip2 -9k $name.tar
fi
if [ $comp = tgz ] ; then
echo "Creating $name.tar.gz"
gzip -9c $name.tar > $name.tar.gz
fi
rm $name.tar
;;
zip)
echo "Creating $name.zip"
zip -q -9 -r $name.zip $name
;;
zip-7z)
echo "Creating $name.zip"
7za a -bd -tzip $name.zip $name > /dev/null
;;
7z)
echo "Creating $name.7z"
7za a -bd $name.7z $name > /dev/null
;;
*)
echo "WARNING: ignoring compression '$comp', not known!"
;;
esac
done
# Remove directory with current dist set
rm -rf $name
done
# Cleanup
rm -rf phpMyAdmin-${target}
if [ "$mode" != "snapshot" ]
then
echo ""
echo ""
echo ""
echo "Files:"
echo "------"
ls -la *.gz *.zip *.bz2 *.7z
echo
echo "MD5 sums:"
echo "--------"
md5sum *.{gz,zip,bz2,7z} | sed "s/\([^ ]*\)[ ]*\([^ ]*\)/md5sum['\2'] = '\1'/"
echo
echo "Add these to website/data/md5sums.py in SVN"
cat <<END
Todo now:
---------
1. tag the subversion tree with the new revision number for a plain release
or a release candidate:
version 2.7.0 gets two tags: RELEASE_2_7_0 and STABLE
version 2.7.1-rc1 gets RELEASE_2_7_1RC1 and TESTING
2. upload the files to SF (procedure explained on the sf.net Admin/File Releases page)
3. add files to SF files page (cut and paste changelog since last release)
4. add SF news item to phpMyAdmin project
5. update web page:
- add MD5s to website/data/md5sums.py in SVN
6. announce release on freshmeat (http://freshmeat.net/projects/phpmyadmin/)
7. send a short mail (with list of major changes) to
phpmyadmin-devel@lists.sourceforge.net
phpmyadmin-news@lists.sourceforge.net
phpmyadmin-users@lists.sourceforge.net
Don't forget to update the Description section in the announcement,
based on Documentation.html.
8. increment rc count or version in subversion :
- in libraries/Config.class.php PMA_Config::__constructor() the line
" $this->set( 'PMA_VERSION', '2.7.1-dev' ); "
- in Documentation.html the 2 lines
" <title>phpMyAdmin 2.2.2-rc1 - Documentation</title> "
" <h1>phpMyAdmin 2.2.2-rc1 Documentation</h1> "
- in translators.html
9. add a group for bug tracking this new version, at
https://sourceforge.net/tracker/admin/index.php?group_id=23067&atid=377408&add_group=1
10. the end :-)
END
fi
# Removed due to not needed thanks to clever scripting by Robbat2
# 9. update the demo subdirectory:
# - in htdocs, cvs update phpMyAdmin
# - and don't forget to give write rights for the updated scripts to the
# whole group

174
scripts/create_tables.sql Normal file
View File

@@ -0,0 +1,174 @@
-- --------------------------------------------------------
-- SQL Commands to set up the pmadb as described in Documentation.html.
--
-- This file is meant for use with MySQL 5 and above!
--
-- This script expects the user pma to already be existing. If we would put a
-- line here to create him too many users might just use this script and end
-- up with having the same password for the controluser.
--
-- This user "pma" must be defined in config.inc.php (controluser/controlpass)
--
-- Please don't forget to set up the tablenames in config.inc.php
--
-- $Id$
-- --------------------------------------------------------
--
-- Database : `phpmyadmin`
--
CREATE DATABASE IF NOT EXISTS `phpmyadmin`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
USE phpmyadmin;
-- --------------------------------------------------------
--
-- Privileges
--
-- (activate this statement if necessary)
-- GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO
-- 'pma'@localhost;
-- --------------------------------------------------------
--
-- Table structure for table `pma_bookmark`
--
CREATE TABLE IF NOT EXISTS `pma_bookmark` (
`id` int(11) NOT NULL auto_increment,
`dbase` varchar(255) NOT NULL default '',
`user` varchar(255) NOT NULL default '',
`label` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '',
`query` text NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE=MyISAM COMMENT='Bookmarks'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma_column_info`
--
CREATE TABLE IF NOT EXISTS `pma_column_info` (
`id` int(5) unsigned NOT NULL auto_increment,
`db_name` varchar(64) NOT NULL default '',
`table_name` varchar(64) NOT NULL default '',
`column_name` varchar(64) NOT NULL default '',
`comment` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '',
`mimetype` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '',
`transformation` varchar(255) NOT NULL default '',
`transformation_options` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `db_name` (`db_name`,`table_name`,`column_name`)
)
ENGINE=MyISAM COMMENT='Column information for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma_history`
--
CREATE TABLE IF NOT EXISTS `pma_history` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`username` varchar(64) NOT NULL default '',
`db` varchar(64) NOT NULL default '',
`table` varchar(64) NOT NULL default '',
`timevalue` timestamp(14) NOT NULL,
`sqlquery` text NOT NULL,
PRIMARY KEY (`id`),
KEY `username` (`username`,`db`,`table`,`timevalue`)
)
ENGINE=MyISAM COMMENT='SQL history for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma_pdf_pages`
--
CREATE TABLE IF NOT EXISTS `pma_pdf_pages` (
`db_name` varchar(64) NOT NULL default '',
`page_nr` int(10) unsigned NOT NULL auto_increment,
`page_descr` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '',
PRIMARY KEY (`page_nr`),
KEY `db_name` (`db_name`)
)
ENGINE=MyISAM COMMENT='PDF relation pages for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma_relation`
--
CREATE TABLE IF NOT EXISTS `pma_relation` (
`master_db` varchar(64) NOT NULL default '',
`master_table` varchar(64) NOT NULL default '',
`master_field` varchar(64) NOT NULL default '',
`foreign_db` varchar(64) NOT NULL default '',
`foreign_table` varchar(64) NOT NULL default '',
`foreign_field` varchar(64) NOT NULL default '',
PRIMARY KEY (`master_db`,`master_table`,`master_field`),
KEY `foreign_field` (`foreign_db`,`foreign_table`)
)
ENGINE=MyISAM COMMENT='Relation table'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma_table_coords`
--
CREATE TABLE IF NOT EXISTS `pma_table_coords` (
`db_name` varchar(64) NOT NULL default '',
`table_name` varchar(64) NOT NULL default '',
`pdf_page_number` int(11) NOT NULL default '0',
`x` float unsigned NOT NULL default '0',
`y` float unsigned NOT NULL default '0',
PRIMARY KEY (`db_name`,`table_name`,`pdf_page_number`)
)
ENGINE=MyISAM COMMENT='Table coordinates for phpMyAdmin PDF output'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma_table_info`
--
CREATE TABLE IF NOT EXISTS `pma_table_info` (
`db_name` varchar(64) NOT NULL default '',
`table_name` varchar(64) NOT NULL default '',
`display_field` varchar(64) NOT NULL default '',
PRIMARY KEY (`db_name`,`table_name`)
)
ENGINE=MyISAM COMMENT='Table information for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma_designer_coords`
--
CREATE TABLE IF NOT EXISTS `pma_designer_coords` (
`db_name` varchar(64) NOT NULL default '',
`table_name` varchar(64) NOT NULL default '',
`x` INT,
`y` INT,
`v` TINYINT,
`h` TINYINT,
PRIMARY KEY (`db_name`,`table_name`)
)
ENGINE=MyISAM COMMENT='Table coordinates for Designer'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

105
scripts/decode_bug.php Normal file
View File

@@ -0,0 +1,105 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Parser BUG decoder
*
* This is the parser bug decoder system
* Throw the bug data in teh query box, and hit submit for output.
*
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
*
* @version $Id$
* @package phpMyAdmin-debug
*/
/**
* Displays the form
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>phpMyAdmin - Parser BUG decoder</title>
<style type="text/css">
<!--
body, p {
font-family: Arial, Helvetica, sans-serif;
font-size: medium;
}
h1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: large;
font-weight: bold;
color: #000066;
}
//-->
</style>
</head>
<body bgcolor="#FFFFFF">
<h1>Parser BUG decoder</h1>
<br />
<form method="post" action="./decode_bug.php">
<input type="hidden" name="bar" value="<?php echo rand(); ?>" />
Encoded bug report:<br />
<textarea name="bug_encoded" cols="72" rows="10"></textarea>
<br /><br />
<input type="submit" />
</form>
<hr />
<?php
/**
* If the form has been submitted -> decodes the bug report
*/
/**
* Display the decoded bug report in ASCII format
*
* @param string the text data
*
* @return string the text enclosed by "<pre>...</pre>" tags
*
* @access public
*/
function PMA_printDecodedBug($textdata)
{
return '<pre>' . htmlspecialchars($textdata) . '</pre><br />';
} // end of the "PMA_printDecodedBug()" function
if (!empty($_POST) && isset($_POST['bug_encoded'])) {
$bug_encoded = $_POST['bug_encoded'];
}
if (!empty($bug_encoded)) {
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
$bug_encoded = stripslashes($bug_encoded);
}
$bug_encoded = preg_replace('/[[:space:]]/', '', $bug_encoded);
$bug_decoded = base64_decode($bug_encoded);
if (substr($bug_encoded, 0, 2) == 'eN') {
if (function_exists('gzuncompress')) {
$result = PMA_printDecodedBug(gzuncompress($bug_decoded));
} else {
$result = 'Error: &quot;gzuncompress()&quot; is unavailable!' . "\n";
}
} else {
$result = PMA_printDecodedBug($bug_decoded);
} // end if... else...
echo '<p>Decoded:</p>' . "\n"
. $result . "\n";
} // end if
?>
</body>
</html>

35
scripts/find_unused_messages.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/sh
export LANG=C
set -e
# Simple script to find unused message strings by Michal Čihař
tmp1=`mktemp`
tmp2=`mktemp`
grep -o '^\$\<str[A-Z][a-zA-Z0-9_]*\>' lang/english-utf-8.inc.php \
| tr -d '$' \
| grep -Ev '^str(Transformation_|ShowStatus)' | sort -u > $tmp1
grep -ho '\<str[A-Z][a-zA-Z0-9_]*\>' `find . -type f -a -name '*.php' -a -not -path '*/lang/*'` \
| grep -Ev '^str(Transformation_|ShowStatus|Lang|Locale|SetupForm_|SetupFormset_)' | sort -u > $tmp2
echo Please note that you need to check results of this script, it doesn\'t
echo understand PHP, it only tries to find what looks like message name.
echo
echo Used messages not present in english language file:
echo '(this contains generated messages and composed message names, so these'
echo 'are not necessary a errors!)'
echo
# filter out known false positives
diff $tmp1 $tmp2 | awk '/^>/ {print $2}' | grep -Ev '(strEncto|strXkana|strDBLink|strPrivDesc|strPrivDescProcess|strTableListOptions|strMissingParameter|strAttribute|strDoSelectAll)'
echo
echo Not used messages present in english language file:
echo
diff $tmp1 $tmp2 | awk '/^</ {print $2}' | grep -Ev '(strSetup.*_(desc|name)|strSetupForm_|strSetupFormset_)'
rm -f $tmp1 $tmp2

76
scripts/lang-cleanup.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/sh
#
# $Id$
# vim: expandtab sw=4 ts=4 sts=4:
#
# Script for removing language selection from phpMyAdmin
if [ $# -lt 1 ] ; then
echo "Usage: lang-cleanup.sh type ..."
echo "Type can be one of:"
echo " all-languages - nothing will be done"
echo " all-languages-utf-8-only - non utf-8 languages will be deleted"
echo " language - keeps utf-8 version of language"
echo " language-charset - keeps this exact language"
echo
echo "Types can be entered multiple times, all matched languages will be kept"
exit 1
fi
# Construct expressions for find
match=""
for type in "$@" ; do
case $type in
all-languages)
match="$match -and -false"
;;
all-languages-utf-8-only)
match="$match -and -not -name *-utf-8.inc.php"
;;
*)
if [ -f lang/$type-utf-8.inc.php ] ; then
match="$match -and -not -name $type-utf-8.inc.php"
elif [ -f lang/$type.inc.php ] ; then
match="$match -and -not -name $type.inc.php"
else
echo "ERROR: $type seems to be wrong!"
exit 2
fi
;;
esac
done
# Delete unvanted languages
find lang -name \*.inc.php $match -print0 | xargs -0r rm
# Cleanup libraries/select_lang.lib.php
# Find languages we have
langmatch="$(awk -F, \
'BEGIN { pr = 1 } ;
/^\);/ { pr = 1 } ;
{if(!pr) print $2;};
/^\$available_languages/ { pr = 0 };' \
libraries/select_lang.lib.php \
| tr -d \' \
| while read lng ; do if [ -f lang/$lng.inc.php ] ; then echo $lng ; fi ; done \
| tr '\n' '|' \
| sed 's/|$//' \
)"
# Prepare working copy
tmp=`mktemp libraries/select_lang.lib.php.XXXX`
cat libraries/select_lang.lib.php > $tmp
# Remove languages we don't have
awk -F, \
'BEGIN { pr = 1 } ;
/^\);/ { pr = 1 } ;
{if(pr) print $0;};
/'$langmatch'/ {if (!pr) print $0;};
/^\$available_languages/ { pr = 0 };' \
$tmp > libraries/select_lang.lib.php
# Final cleanup
rm -f $tmp

23
scripts/remove_control_m.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/sh
#
# $Id$
#
# Script to remove ^M from files for DOS <-> UNIX conversions
#
if [ $# != 1 ]
then
echo "Usage: remove_control_m.sh <extension of files>"
echo ""
echo "Example: remove_control_m.sh php3"
exit
fi
for i in `find . -name "*.$1"`
do
echo $i
tr -d '\015' < $i > ${i}.new
rm $i
mv ${i}.new $i
done;

56
scripts/signon.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Single signon for phpMyAdmin
*
* This is just example how to use single signon with phpMyAdmin, it is
* not intended to be perfect code and look, only shows how you can
* integrate this functionality in your application.
*
* @version $Id$
* @package phpMyAdmin
* @subpackage Example
*/
/* Was data posted? */
if (isset($_POST['user'])) {
/* Need to have cookie visible from parent directory */
session_set_cookie_params(0, '/', '', 0);
/* Create signon session */
$session_name = 'SignonSession';
session_name($session_name);
session_start();
/* Store there credentials */
$_SESSION['PMA_single_signon_user'] = $_POST['user'];
$_SESSION['PMA_single_signon_password'] = $_POST['password'];
$_SESSION['PMA_single_signon_host'] = $_POST['host'];
$id = session_id();
/* Close that session */
session_write_close();
/* Redirect to phpMyAdmin (should use absolute URL here!) */
header('Location: ../index.php');
} else {
/* Show simple form */
header('Content-Type: text/html; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<title>phpMyAdmin single signon example</title>
</head>
<body>
<form action="signon.php" method="post">
Username: <input type="text" name="user" /><br />
Password: <input type="password" name="password" /><br />
Host: (will use the one from config.inc.php by default) <input type="text" name="host" /><br />
<input type="submit" />
</form>
</body>
</html>
<?php
}
?>

223
scripts/upgrade.pl Executable file
View File

@@ -0,0 +1,223 @@
#!/usr/bin/perl
#
# $Id$
#
# upgrade.pl - automatic phpmyadmin upgrader
#
#
# 2005-05-08, swix@users.sourceforge.net:
# - created script
#
# 2005-10-29 swix@users.sourceforge.net:
# - some fixes & improvements
#
use strict;
my $source_url = "http://phpmyadmin.net/home_page/version.php";
#
# usage
#
if (!$ARGV[0] || (($ARGV[0] eq "--force") && !$ARGV[1])) {
print "\n";
print "usage: $0 [--force] <target_directory>\n\n";
print " The location specified by <target_directory> will be backed up and replaced\n";
print " by the latest stable version of phpMyAdmin.\n";
print " Your config.inc.php file will be preserved.\n\n";
exit(0);
}
my $forced;
my $targetdirectory;
if ($ARGV[0] eq "--force") {
$forced = 1;
$targetdirectory = $ARGV[1];
} else {
$forced = 0;
$targetdirectory = $ARGV[0];
}
if ($targetdirectory =~ /^(.*)\/$/) {
# remove trailing slash, if any
$targetdirectory = $1;
}
if (!-d $targetdirectory) {
print "error: target directory ($targetdirectory) does not exists\n";
exit(0);
}
if (!-f "$targetdirectory/config.inc.php") {
print "error: target directory doesn't seem to contain phpMyAdmin\n";
exit(0);
}
#
# get current release information
#
my $version;
my $filename;
my $directory;
my $releasedate;
my @urls;
my @today;
my $installedversion;
if (open(LATEST, "wget -o /dev/null -O - $source_url|")) {
$version = <LATEST>; chomp($version);
$releasedate = <LATEST>; chomp($releasedate);
$filename = "phpMyAdmin-" . $version . "-all-languages.tar.gz";
$directory = "phpMyAdmin-" . $version . "-all-languages";
my $i = 0;
while (my $line = <LATEST>) {
chomp($line);
if ($line =~ /http/) {
$urls[$i++] = $line;
}
}
close(LATEST);
} else {
print "error: open of $source_url failed.\n";
exit(0);
}
if (-d $directory) {
print "error: target directory ($directory) already exists, exiting\n";
exit(0);
}
#
# check the installed version
#
if (open(DEFINES, $targetdirectory .'/libraries/Config.class.php')) {
my $versionStatus = 0;
$installedversion = "unknownversion";
while (my $line = <DEFINES>) {
next unless $line =~ /'PMA_VERSION',\ '(.*)?'\);$/;
$installedversion = $1;
# take care of "pl", "rc" and "dev": dev < rc < pl
my $converted_installedversion = $installedversion;
$converted_installedversion =~ s/dev/aaa/g;
$converted_installedversion =~ s/rc/bbb/g;
$converted_installedversion =~ s/pl/ccc/g;
my $converted_version = $version;
$converted_version =~ s/dev/aaa/g;
$converted_version =~ s/rc/bbb/g;
$converted_version =~ s/pl/ccc/g;
if ($converted_installedversion gt $converted_version && !$forced) {
print "Local version ($installedversion) newer than latest stable release ($version), not updating. (use \"--force\")\n";
exit(0);
} elsif ($installedversion eq $version && !$forced) {
print "Local version ($version) already up to date, not updating (you can use \"--force\")\n";
exit(0);
} else {
$versionStatus = 1;
}
}
if (!$versionStatus && !$forced) {
print "Old version could not be identified, not updating (use \"--force\" if you are sure) \n";
exit(0);
}
}
#
# ask for confirmation
#
print "\n";
print "phpMyAdmin upgrade summary:\n";
print "---------------------------\n";
print " phpMyAdmin Path: $targetdirectory\n";
print " Installed version: $installedversion\n";
print " Upgraded version: $version\n\n";
print "Proceed with upgrade? [Y/n] ";
my $kbdinput = <STDIN>; chomp($kbdinput);
if (lc(substr($kbdinput,0,1)) ne "y" && length($kbdinput) >= 1) {
print "Aborting.\n";
exit(0);
} else {
print "Proceeding...\n\n";
}
#
# get file
#
if (!-f $filename) {
print "getting phpMyAdmin $version\n";
foreach my $url (@urls) {
print "trying $url...\n";
system("wget -o /dev/null $url");
if (-f $filename) {
print "-> ok\n";
last;
}
}
} else {
print "already got $filename, not downloading\n";
}
if (!-f $filename) {
print "error: $filename download failed\n";
exit(0);
}
#
# setup
#
print "installing...\n";
system("tar xzf $filename");
if (!$directory) {
print "error: $directory still not exists after untar...\n";
exit(0);
}
@today = localtime(time); $today[4]++; $today[5]+=1900;
my $timestamp = sprintf("%04d%02d%02d%02d%02d", $today[5], $today[4], $today[3], $today[2], $today[1]);
my $backupdir = $targetdirectory . "-" . $timestamp . "-" . $installedversion;
print "- backup directory: $backupdir\n";
system("cp $directory/config.inc.php $directory/config.inc-dist.php");
print "- original distribution config.inc.php renamed to config.inc-dist.php\n";
system("cp $targetdirectory/config.inc.php $directory/config.inc.php");
print "- previous config.inc.php copied to the new setup\n";
system("mv $targetdirectory $backupdir");
system("mv $directory $targetdirectory");
system("rm $filename");
print "\ndone! phpMyAdmin $version installed in $targetdirectory\n";
print "backup of your old installation in $backupdir\n";
print "Enjoy! :-)\n\n";

View File

@@ -0,0 +1,164 @@
-- -------------------------------------------------------------
-- SQL Commands to upgrade pmadb for normal phpMyAdmin operation
-- with MySQL 4.1.2 and above.
--
-- This file is meant for use with MySQL 4.1.2 and above!
-- For older MySQL releases, please use create_tables.sql
--
-- If you are running one MySQL 4.1.0 or 4.1.1, please create the tables using
-- create_tables.sql, then use this script.
--
-- Please don't forget to set up the tablenames in config.inc.php
--
-- $Id$
-- --------------------------------------------------------
--
-- Database : `phpmyadmin`
--
ALTER DATABASE `phpmyadmin`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
USE phpmyadmin;
-- --------------------------------------------------------
--
-- Table structure for table `pma_bookmark`
--
ALTER TABLE `pma_bookmark`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE `pma_bookmark`
CHANGE `dbase` `dbase` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_bookmark`
CHANGE `user` `user` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_bookmark`
CHANGE `label` `label` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
ALTER TABLE `pma_bookmark`
CHANGE `query` `query` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;
-- --------------------------------------------------------
--
-- Table structure for table `pma_column_info`
--
ALTER TABLE `pma_column_info`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE `pma_column_info`
CHANGE `db_name` `db_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_column_info`
CHANGE `table_name` `table_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_column_info`
CHANGE `column_name` `column_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_column_info`
CHANGE `comment` `comment` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
ALTER TABLE `pma_column_info`
CHANGE `mimetype` `mimetype` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
ALTER TABLE `pma_column_info`
CHANGE `transformation` `transformation` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_column_info`
CHANGE `transformation_options` `transformation_options` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
-- --------------------------------------------------------
--
-- Table structure for table `pma_history`
--
ALTER TABLE `pma_history`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE `pma_history`
CHANGE `username` `username` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_history`
CHANGE `db` `db` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_history`
CHANGE `table` `table` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_history`
CHANGE `sqlquery` `sqlquery` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;
-- --------------------------------------------------------
--
-- Table structure for table `pma_pdf_pages`
--
ALTER TABLE `pma_pdf_pages`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE `pma_pdf_pages`
CHANGE `db_name` `db_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_pdf_pages`
CHANGE `page_descr` `page_descr` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '';
-- --------------------------------------------------------
--
-- Table structure for table `pma_relation`
--
ALTER TABLE `pma_relation`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE `pma_relation`
CHANGE `master_db` `master_db` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_relation`
CHANGE `master_table` `master_table` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_relation`
CHANGE `master_field` `master_field` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_relation`
CHANGE `foreign_db` `foreign_db` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_relation`
CHANGE `foreign_table` `foreign_table` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_relation`
CHANGE `foreign_field` `foreign_field` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
-- --------------------------------------------------------
--
-- Table structure for table `pma_table_coords`
--
ALTER TABLE `pma_table_coords`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE `pma_table_coords`
CHANGE `db_name` `db_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_table_coords`
CHANGE `table_name` `table_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
-- --------------------------------------------------------
--
-- Table structure for table `pma_table_info`
--
ALTER TABLE `pma_table_info`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE `pma_table_info`
CHANGE `db_name` `db_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_table_info`
CHANGE `table_name` `table_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
ALTER TABLE `pma_table_info`
CHANGE `display_field` `display_field` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
-- --------------------------------------------------------
--
-- Table structure for table `pma_designer_coords`
--
CREATE TABLE IF NOT EXISTS `pma_designer_coords` (
`db_name` varchar(64) NOT NULL default '',
`table_name` varchar(64) NOT NULL default '',
`x` INT,
`y` INT,
`v` TINYINT,
`h` TINYINT,
PRIMARY KEY (`db_name`,`table_name`)
)
ENGINE=MyISAM COMMENT='Table coordinates for Designer'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;