📄 common.lib.php
字号:
<?php/*** Web based SQLite management* Some functions* @package SQLiteManager* @author Fr閐閞ic HENNINOT* @version $Id: common.lib.php,v 1.126 2006/04/18 07:18:52 freddy78 Exp $ $Revision: 1.126 $*//*** check if SQLite extension is loaded, and if not load it.*/function CheckExtension($extName) { $SQL_SERVER_OS = strtoupper(substr(PHP_OS, 0, 3)); if($SQL_SERVER_OS == 'WIN') { $preffix= 'php_'; $suffix = '.dll'; } elseif($SQL_SERVER_OS == 'NET') { $preffix= 'php_'; $suffix = '.nlm'; } elseif(($SQL_SERVER_OS == 'LIN') || ($SQL_SERVER_OS == 'DAR')) { $preffix= ''; $suffix = '.so'; } $extensions = get_loaded_extensions(); foreach ($extensions as $key=>$ext) $extensions[$key] = strtolower($ext); if (!extension_loaded($extName) && !in_array($extName, get_loaded_extensions())) { if(DEBUG) { $oldLevel = error_reporting(); error_reporting(E_ERROR); $extensionLoaded = dl($preffix.$extName.$suffix); error_reporting($oldLevel); } else { $extensionLoaded = @dl($preffix.$extName.$suffix); } if ($extensionLoaded) { return true; } else { return false; } } else return true;}/*** Display error message* * @param string $message */function displayError($message){ echo ' <center> <table width="80%" style="border: 1px solid red;" class="error"> <tr><td align="center"><b>'.$GLOBALS['traduct']->get(9).' :</b></td></tr> <tr><td align="left"><span style="color: red"><b>'.$message.'</b></span></td></tr> </table> </center>'; return;}/*** return the condition*/function displayCondition($authType){ global $SQLiteManagerAuth; return (!WITH_AUTH || ( isset($SQLiteManagerAuth) && $SQLiteManagerAuth->getAccess($authType) )); }/*** Get plugins array*/function getPlugins(){ $res = array(); if ($dir = @opendir('plugins')) { while ($element = readdir($dir)) { if (substr($element,0,1) != '.' && $element!='CVS') if (is_dir('plugins/'.$element)) $res[] = 'plugins/'.$element.'/'; } closedir($dir); } return $res;}/*** Display the global menu on the right pan, it' dependant of context*/function displayMenuTitle(){ global $SQLiteManagerAuth, $workDb; $linkBase = 'main.php?dbsel='.$GLOBALS['dbsel']; foreach($GLOBALS['dbItems'] as $Items) if(isset($GLOBALS[strtolower($Items)])) $linkBase .= '&'.strtolower($Items).'='.$GLOBALS[strtolower($Items)]; $out = ''; $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(72),'url'=> $linkBase.'&action=properties'); if(isset($GLOBALS['table']) && ($GLOBALS['table']!='')){ if(isset($_REQUEST['currentPage'])) $valCurrent = $_REQUEST['currentPage']; else $valCurrent = $GLOBALS['action']; $Context='Table'; //Items : txt:Text, url:Link, enabled, type, hint, confirm, ... $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(73),'url'=> $linkBase.'&action=browseItem'); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(74),'url'=> $linkBase.'&action=sql', 'enabled'=> (displayCondition('execSQL'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(206),'url'=> $linkBase.'&action=select'); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(75),'url'=> $linkBase.'&action=insertElement¤tPage='.$valCurrent, 'enabled'=> (displayCondition('data') && !$workDb->isReadOnly())); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(222),'url'=> $linkBase.'&action=operation', 'enabled'=> (displayCondition('properties'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(76),'url'=> $linkBase.'&action=export', 'enabled'=> (displayCondition('export'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(77),'url'=> $linkBase.'&action=empty', 'confirm'=> $GLOBALS['traduct']->get(79), 'enabled'=> (displayCondition('empty') && !$workDb->isReadOnly())); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(15),'url'=> $linkBase.'&action=delete', 'confirm'=> $GLOBALS['traduct']->get(80), 'enabled'=> (displayCondition('del') && !$workDb->isReadOnly())); } elseif(isset($GLOBALS['view']) && ($GLOBALS['view']!='')) { $Context='View'; $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(73),'url'=> $linkBase.'&action=browseItem'); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(74),'url'=> $linkBase.'&action=sql', 'enabled'=> (displayCondition('execSQL'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(206,'Select'),'url'=> $linkBase.'&action=select', 'enabled'=> (displayCondition('execSQL'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(76),'url'=> $linkBase.'&action=export', 'enabled'=> (displayCondition('export'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(81),'url'=> $linkBase.'&action=add', 'enabled'=> (displayCondition('properties'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(15),'url'=> $linkBase.'&action=delete', 'confirm'=> $GLOBALS['traduct']->get(82), 'enabled'=> (displayCondition('del') && !$workDb->isReadOnly())); } elseif(isset($GLOBALS['function']) && ($GLOBALS['function']!='')) { $Context='Function'; $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(74),'url'=> $linkBase.'&action=sql', 'enabled'=> (displayCondition('execSQL'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(76),'url'=> $linkBase.'&action=export', 'enabled'=> (displayCondition('export'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(81),'url'=> $linkBase.'&action=add', 'enabled'=> (displayCondition('properties'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(15),'url'=> $linkBase.'&action=delete', 'confirm'=> $GLOBALS['traduct']->get(78), 'enabled'=> (displayCondition('del') && !$workDb->isReadOnly())); } elseif(isset($GLOBALS['trigger']) && ($GLOBALS['trigger']!='')) { $Context='Trigger'; $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(74),'url'=> $linkBase.'&action=sql', 'enabled'=> (displayCondition('execSQL'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(81),'url'=> $linkBase.'&action=add', 'enabled'=> (displayCondition('properties'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(15),'url'=> $linkBase.'&action=delete', 'confirm'=> $GLOBALS['traduct']->get(83), 'enabled'=> (displayCondition('del') && !$workDb->isReadOnly())); } else { $Context='Database'; $hintContext = html_entity_decode($GLOBALS['traduct']->get(131), ENT_NOQUOTES, $GLOBALS['charset']); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(84),'url'=> $linkBase.'&action=options'); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(74),'url'=> $linkBase.'&action=sql', 'enabled'=> (displayCondition('execSQL'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(76),'url'=> $linkBase.'&action=export', 'enabled'=> (displayCondition('export'))); $menuItems[] = array('txt'=> $GLOBALS['traduct']->get(15),'url'=> $linkBase.'&action=del', 'confirm'=> $GLOBALS['traduct']->get(85), 'enabled'=> (displayCondition('del'))); } if (!isset($hintContext)) $hintContext = $GLOBALS['itemTranslated'][$Context]; if(ALLOW_EXEC_PLUGIN){ $plugins = getPlugins(); foreach($plugins as $plugin_path) { $plugin_menu = array(); include_once($plugin_path.'plugin.php'); if (@$plugin_menu[$Context]) { $menu = 'plugin_'.$Context.'Menu'; $pluginItems = @$$menu; if (isset($pluginsItems) && @count($pluginsItems)) foreach ($pluginsItems as $key=>$item) if (array_key_exists('hint',$item)) $pluginItems[$key]['hint'] = $hintContext.' : '.$plugin_name.' : '.$item['hint']; elseif (isset($item['txt'])) $pluginItems[$key]['hint'] = $hintContext.' : '.$plugin_name.' : '.$item['txt']; if (isset($pluginItems)) foreach ($pluginItems as $item) $pluginsItems[] = $item; } } if (isset($pluginsItems)) { $menuItems[] = array('type'=>'_cmSplit'); $menuItems[] = array('type'=>'folder', 'txt'=> $GLOBALS['traduct']->get(211,'Plugins'), 'url'=>'#'); foreach ($pluginsItems as $item) $menuItems[] = $item; $menuItems[] = array('type'=>'endfolder'); } $menuItems[] = array('type'=>'_cmSplit'); } /* Javascript Menu */ $out .= "\n\t\t\t".'<script type="text/javascript">'. "\n\t\t\t\t".'var jsMenu = ['; $icon=''; $inFolder=''; $target='main'; foreach ($menuItems as $item) { $confirm = ''; $title = (isset($item['txt']))? $item['txt'] : ''; $icon = (array_key_exists('icon',$item))?'<img class="seq1" src="'.$item['icon'].'"><img class="seq2" src="'.$item['icon'].'">':' '; $description = (array_key_exists('hint',$item))? $item['hint'] : $hintContext.' : '.$title; $description = addslashes(html_entity_decode($description, ENT_NOQUOTES, $GLOBALS['charset'])); if (!array_key_exists('enabled',$item) || @$item['enabled']) { $url = (isset($item['url']))? $item['url'] : ''; if (isset($item['confirm'])) { $confirm = addslashes(html_entity_decode($item['confirm'], ENT_NOQUOTES, $GLOBALS['charset'])); } } else { $url = ''; $title = '<i>'.$title.'</i>'; $description = '[DISABLED] '.$description; } if ($url=='') $url='#'; $line = "\n\t\t\t\t".$inFolder."['$icon', '$title', '$url', '$target', '$description', '$confirm'"; if (!isset($item['type'])) { $line .= '],'; } else if ($item['type']=='endfolder') { $out = substr($out,0,strlen($out)-1); $line = "\n\t\t\t\t".'],'; $inFolder=''; } elseif ($item['type']=='folder') { $line .= ','; $inFolder .= "\t"; } else { $line = "\n\t\t\t\t".$item['type'].','; } $out .= $line; } $out = substr($out,0,strlen($out)-1); global $jsmenu_style; if (!isset($jsmenu_style)) $jsmenu_style = 'hbr'; $out .= "\n\t\t\t\t"."];". "\n\t\t\t\t"."cmDraw ('CommandMenu', jsMenu, '$jsmenu_style', cmThemeOffice, 'ThemeOffice');". "\n\t\t\t"."</script>"."\n\t\t";/* */ echo '<!-- common.lib.php : displayMenuTitle() -->'."\n"; echo ' <div align="center"> <table class="menu" cellspacing="0" cellpadding="0"> <tr><td> <div id="CommandMenu">'.$out.'</div> </td></tr> </table> </div>';}/*** Display pan header** @param string $frame target where the header will be display* @param bool $withTitle display title*/function displayHeader($frame, $withTitle=true){ global $workDb; $GlobalTheme = $GLOBALS['localtheme'].'/'.$frame; if(is_readable('theme/'.$GLOBALS['localtheme'].'/menu/theme.css')) $menuTheme = $GLOBALS['localtheme']; else $menuTheme = 'default'; ?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title><?php echo $GLOBALS['traduct']->get(3)." ".$GLOBALS['SQLiteVersion'] ?></title> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="content-type" content="text/html;charset=<?php echo $GLOBALS['charset'] ?>"> <style type="text/css"> /* to add later in all themes, now can be supersed by theme*/ table.menu { border-bottom: 1px solid black; width: 80%;} table.menuButtons { width: 70%; } td.viewPropTitle { border: 1px solid white; } td.viewProp { border: 1px solid white; } table.home { width: 90%; text-align: center; } td.boxtitle { width: 49%; text-align: center; } td.boxtitlespace { width: 2%; font-size:0px; padding:0px; } h5 { margin-bottom: 3px; font-size: 12px; } table.query { width: 60%; margin-top: 10px; } div.BrowseOptions { text-align:left; } table.BrowseOption { text-align:left; } div.TableOptions { text-align: left; } table.Indexes { margin: 5px; width: 70%; border: thin grey solid; text-align: center; } body { font-size: 12px; } .Tip { font-size: 10px; background-color : Silver; } .time { font-size: 10px; float: center } div.Rights { border: 1px solid blue; } </style> <link href="theme/<?php echo $menuTheme?>/menu/theme.css" rel="stylesheet" type="text/css"> <link href="theme/<?php echo $GlobalTheme?>.css" rel="stylesheet" type="text/css"> <script src="include/function.js" type="text/javascript" language="javascript"></script> <script src="include/JSCookMenu.js" type="text/javascript" language="javascript"></script> <script src="theme/<?php echo $menuTheme?>/menu/theme.js" type="text/javascript" language="javascript"></script> <?phpif(isset($GLOBALS['GlobalCalendar'])) echo $GLOBALS['GlobalCalendar']->get_load_files_code() . "\n";?> </head> <body> <?php if( ($frame == 'main') && ($withTitle) && ($GLOBALS['dbsel']) ){ echo '<h2 class="sqlmVersion">'.$GLOBALS['traduct']->get(131).' : <a href="main.php?dbsel='.$GLOBALS['dbsel'].'" style="text-decoration: none;"><span style="color: red;">'.$GLOBALS['tabInfoDb']['name'].'</span></a>'; foreach($GLOBALS['dbItems'] as $Items) { if(!empty($GLOBALS[strtolower($Items)])) echo ' - '.$GLOBALS['itemTranslated'][$Items].' <a href="main.php?dbsel='.$GLOBALS['dbsel'].'&'.strtolower($Items).'='.$GLOBALS[strtolower($Items)].'" style="text-decoration: none;" target="main"><span style="color: blue;">'.$GLOBALS[strtolower($Items)].'</span></a>'; } echo '</h2>'."\n"; if($workDb->isReadOnly()){ if($workDb->isReadable()) $message = $GLOBALS['traduct']->get(155); else $message = $GLOBALS['traduct']->get(232); echo '<table width="80%" align="center"><tr><td style="font-size: 10px; border: 1px solid red; color: red; align: center;">'.$message.'</td></tr></table>'; } }}/*** Display add form dependent of context** @param string $type represent the context*/function formAddItem($type){ switch($type){ case 'Table': echo ' <form name="add'.$type.'" action="main.php" method="POST" target="main"> <span style="font-size: 12px;">'.$GLOBALS['traduct']->get(43).' ==> '.$GLOBALS['traduct']->get(19). ' : <input type="text" name="TableName" size="20" class="small-input"> - <input type="text" name="nbChamps" size="3" class="small-input"> '.$GLOBALS['traduct']->get(44).' <input class="button" type="submit" value="'.$GLOBALS['traduct']->get(69).'"> <input type="hidden" name="dbsel" value="'.$GLOBALS['dbsel'].'"> <input type="hidden" name="action" value="add_'.strtolower($type).'"> </span> </form>'; break; case 'View': echo '<a href="main.php?dbsel='.$GLOBALS['dbsel'].'&action=add_view" class="propItemTitle" target="main"> » '.$GLOBALS['traduct']->get(87).'</a>'; break; case 'Trigger': echo '<a href="main.php?dbsel='.$GLOBALS['dbsel'].'&action=add_trigger" class="propItemTitle" target="main"> » '.$GLOBALS['traduct']->get(88).'</a>';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -