【php开源代码栏目提醒】:网学会员为广大网友收集整理了,pdf_pages.php,希望对大家有所帮助!
<?php
/* $Id: pdf_pages.php,v 2.24 2006/01/17 17:02:29 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Gets some core libraries
*/
require_once('./libraries/common.lib.php');
require_once('./libraries/db_details_common.inc.php');
/**
* Settings for relation stuff
*/
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
// This is to avoid "Command out of sync" errors. Before switching this to
// a value of 0 (for MYSQLI_USE_RESULT), please check the logic
// to free results wherever needed.
$query_default_option = PMA_DBI_QUERY_STORE;
/**
* Now in ./libraries/relation.lib.php we check for all tables
* that we need, but if we don't find them we are quiet about it
* so people can work without.
* This page is absolutely useless if you didn't set up your tables
* correctly, so it is a good place to see which tables we can and
* complain ;-)
*/
if (!$cfgRelation['relwork']) {
echo sprintf($strNotSet, 'relation', 'config.inc.php') . '<br />' . "\n"
. '<a href="./Documentation.html#relation" target="documentation">' . $strDocu . '</a>' . "\n";
require_once('./libraries/footer.inc.php');
}
if (!$cfgRelation['displaywork']) {
echo sprintf($strNotSet, 'table_info', 'config.inc.php') . '<br />' . "\n"
. '<a href="./Documentation.html#table_info" target="documentation">' . $strDocu . '</a>' . "\n";
require_once('./libraries/footer.inc.php');
}
if (!isset($cfgRelation['table_coords'])){
echo sprintf($strNotSet, 'table_coords', 'config.inc.php') . '<br />' . "\n"
. '<a href="./Documentation.html#table_coords" target="documentation">' . $strDocu . '</a>' . "\n";
exit();
}
if (!isset($cfgRelation['pdf_pages'])) {
echo sprintf($strNotSet, 'pdf_page', 'config.inc.php') . '<br />' . "\n"
. '<a href="./Documentation.html#pdf_pages" target="documentation">' . $strDocu . '</a>' . "\n";
exit();
}
if ($cfgRelation['pdfwork']) {
// Now is the time to work on all changes
if (isset($do)) {
switch ($do) {
case 'choosepage':
if ($action_choose=="1") {
$ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND pdf_page_number = ' . $chpage;
PMA_query_as_cu($ch_query, FALSE, $query_default_option);
$ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND page_nr = ' . $chpage;
PMA_query_as_cu($ch_query, FALSE, $query_default_option);
unset($chpage);
}
break;
case 'createpage':
if (!isset($newpage) || $newpage == '') {
$newpage = $strNoDescription;
}
$ins_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
. ' (db_name, page_descr)'
. ' VALUES (\'' . PMA_sqlAddslashes($db) . '\', \'' . PMA_
sqlAddslashes($newpage) . '\')';
PMA_query_as_cu($ins_query, FALSE, $query_default_option);
// A u t o m a t i c l a y o u t
//
// TODO: support InnoDB
if (isset($autolayout)) {
// save the page number
$pdf_page_number = PMA_DBI_insert_id((isset($controllink)?$controllink:''));
// get the tables that have relations, by descending
// number of links
$master_tables = 'SELECT COUNT(master_table), master_table'
. ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $db . '\''
. ' GROUP BY master_table'
. ' ORDER BY ' . PMA_backquote('COUNT(master_table)') . ' DESC ';
$master_tables_rs = PMA_query_as_cu($master_tables, FALSE, $query_default_option);
if ($master_tables_rs && PMA_DBI_num_rows($master_tables_rs) > 0) {
// first put all the master tables at beginning
// of the list, so they are near the center of
// the schema
while (list(, $master_table) = PMA_DBI_fetch_row($master_tables_rs)) {
$all_tables[] = $master_table;
}
// then for each master, add its foreigns into an array
// of foreign tables, if not already there
// (a foreign might be foreign for more than
// one table, and might be a master itself)
$foreign_tables = array();
foreach ($all_tables AS $master_table) {
$foreigners = PMA_getForeigners($db, $master_table);
foreach ($foreigners AS $foreigner) {
if (!in_array($foreigner['foreign_table'], $foreign_tables)) {
$foreign_tables[] = $foreigner['foreign_table'];
}
}
}
// then merge the arrays
for