home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / EasyPHP-2.0b1-setup.exe / {app} / sqlitemanager / main.php < prev    next >
Encoding:
PHP Script  |  2006-04-18  |  7.0 KB  |  189 lines

  1. <?php
  2. /**
  3. * Web based SQLite management
  4. * @package SQLiteManager
  5. * @author FrΘdΘric HENNINOT
  6. * @version $Id: main.php,v 1.45 2006/04/14 20:18:23 freddy78 Exp $ $Revision: 1.45 $
  7. */
  8.  
  9. session_start();
  10. ob_start();
  11. include_once "include/defined.inc.php";
  12. include_once INCLUDE_LIB."config.inc.php";
  13.  
  14. if(ADVANCED_EDITOR && file_exists(SPAW_PATH."spaw_control.class.php") 
  15.     && isset($_COOKIE["SQLiteManager_HTMLon"]) && !$_COOKIE["SQLiteManager_HTMLon"]) {
  16.     $spaw_root = SPAW_PATH;
  17.     $spaw_dir = str_replace($_SERVER["DOCUMENT_ROOT"], "", $spaw_root);
  18.     $spaw_base_url = "http://".$_SERVER["HTTP_HOST"].$spaw_dir;
  19.     include_once SPAW_PATH."spaw_control.class.php";
  20. }
  21. if(JSCALENDAR_USE && file_exists(JSCALENDAR_PATH . 'calendar.php')) {
  22.         include_once JSCALENDAR_PATH . 'calendar.php';
  23.         $GlobalCalendar = new DHTML_Calendar(JSCALENDAR_PATH, $langSuffix, 'calendar-win2k-1', false);
  24. if(empty($dbsel) && ( !isset($GLOBALS["action"]) || ($GLOBALS["action"]!="auth") || (($GLOBALS["action"]=="auth") && !$SQLiteManagerAuth->isAdmin()) )){
  25. displayHeader("main");
  26. ?>
  27. <h2 class="sqlmVersion"><?php echo $traduct->get(2)." ".SQLiteManagerVersion ?></h2>
  28.     <h4 class="serverInfo"><?php echo $traduct->get(3)." ".$SQLiteVersion ?> / <?php echo $traduct->get(150)." ".phpversion() ?></h4>
  29.     <?php if(READ_ONLY) echo '<table width="80%" align="center"><tr><td style="font-size: 10px; border: 1px solid red; color: red; align: center">'.$traduct->get(154).'</td></tr></table>'; ?>
  30.  
  31.     <table align="center" cellspacing="0" cellpadding="0" class="home">
  32.         <tr>
  33.             <td class="boxtitle">SQLite
  34.             </td>
  35.             <td class="boxtitlespace"> 
  36.             </td>
  37.             <td class="boxtitle">SQLiteManager
  38.             </td>
  39.         </tr>
  40.         <tr>
  41.             <td style="white-space: nowrap"><?php include INCLUDE_LIB."add_database.php"; ?></td>
  42.             <td class="space"> </td>
  43.             <td align="left" style="white-space: nowrap"><form action="main.php" method="POST">
  44.                 <table align="center" cellspacing="10" cellpadding="0">
  45.                 <tr><td style="white-space: nowrap"><?php echo $traduct->get(141); ?> : </td>
  46.                 <td><select name="Langue" onChange="submit()"><?php echo getAvailableLanguage(); ?></select></td></tr>
  47.                 <tr><td style="white-space: nowrap"><?php echo $traduct->get(142); ?> : </td>
  48.                 <td><select name="Theme" onChange="submit()"><?php echo getAvailableTheme(); ?></select></td></tr>
  49.                 </table>
  50.         </form>
  51.                      » <a href="http://www.sqlite.org/" target="docs" class="Browse"><?php echo $traduct->get(4); ?></a>
  52.                 <br> » <a href="http://www.sqlite.org/lang.html" target="docs" class="Browse"><?php echo $traduct->get(5); ?></a>
  53.                 <br> » <a href="http://www.sqlitemanager.org" target="docs" class="Browse"><?php echo $traduct->get(231); ?></a>
  54.             </td>
  55.         </tr>
  56.         <tr>
  57.             <td> </td>
  58.             <td class="space"> </td>
  59.               <td>
  60.                 <?php if(WITH_AUTH){ ?> <hr style="border: 1px dashed blue"> <?php } ?>
  61.                 <div style="text-align:left; padding:5px;">
  62.                 <?php if(!READ_ONLY && WITH_AUTH && $SQLiteManagerAuth->isAdmin()) { ?>
  63.                 » <a href="?action=auth" class="Browse"><?php echo $traduct->get(156); ?></a>
  64.                 <?php } ?>
  65.                 <?php if(!READ_ONLY && WITH_AUTH && ALLOW_CHANGE_PASSWD) {
  66.                     if($GLOBALS["action"] != "passwd") { ?>
  67.                 <br>» <a href="main.php?action=passwd" class="Browse"><?php echo $traduct->get(157); ?></a><br><br>
  68.                     <?php } else {
  69.                     // manage passwd
  70.                     echo "<blockquote>";
  71.                     $SQLiteManagerAuth->changePasswd();
  72.                     echo "</blockquote>";
  73.                     } }
  74.                     if(WITH_AUTH){
  75.                     ?>
  76.                 » <a href="index.php?action=logout" target="_parent" class="Browse"><?php echo $traduct->get(158); ?></a>
  77.                     <?php } ?>
  78.                 </div>
  79.             </td>
  80.         </tr>
  81.     </table>
  82. <?php
  83. } elseif(!isset($GLOBALS["action"]) || ($GLOBALS["action"]!="auth")) {
  84.     // gestion de la base selectionnΘ
  85.     include_once INCLUDE_LIB."SQLiteDbConnect.class.php";
  86.     $tempDir = dirname($tabInfoDb['location']);
  87.     if($tempDir == '.') $baseLocation = DEFAULT_DB_PATH . $tabInfoDb['location'];
  88.     else $baseLocation = $tabInfoDb['location'];
  89.     $workDb = &new SQLiteDbConnect($baseLocation);
  90.     
  91.     displayHeader("main");
  92.  
  93.     displayMenuTitle();    
  94.  
  95.     $workDb->includeUDF();
  96.     if(ALLOW_FULLSEARCH){
  97.         include_once INCLUDE_LIB."sqlite_fulltextsearchex.class.php";
  98.         $sqlite_fts = new sqlite_fulltextsearchex ();
  99.         $sqlite_fts->register ($workDb->connId);
  100.         $sqlite_fts->use_against_cache = true; 
  101.     }
  102.     
  103.     switch($action){
  104.         case '':
  105.         case 'properties':
  106.         default:
  107.             if($workDb->isReadable()) {
  108.                 if($table || $TableName) $fileProp = 'tableproperties';
  109.                 elseif($view || $ViewName || isset($_POST['ViewName'])) $fileProp = 'viewproperties';
  110.                 elseif($trigger || $TriggerName) $fileProp = 'triggerproperties';
  111.                 elseif($function) $fileProp = 'functproperties';
  112.                 else $fileProp = 'dbproperties';
  113.                 if (isset($GLOBALS['plugin'])) {
  114.                     include_once 'plugins/'.$GLOBALS['plugin'].'/'.(isset($GLOBALS['file'])?$GLOBALS['file']:'plugin').'.php';
  115.                     if (isset($GLOBALS["action"]) && function_exists('plugin_'.$GLOBALS["action"])) {
  116.                     $function = 'plugin_'.$GLOBALS["action"];
  117.                     $function();
  118.                     break;
  119.                     }
  120.                 }
  121.                 include_once INCLUDE_LIB.$fileProp.'.php';
  122.             }
  123.             break;
  124.         case 'browseItem':
  125.             if($workDb->isReadable()) include INCLUDE_LIB.'browse.php';
  126.             break;
  127.         case 'sql':
  128.             if($workDb->isReadable()) {
  129.                 include INCLUDE_LIB.'sql.php';
  130.                 if ($_SERVER['REQUEST_METHOD'] == 'POST')
  131.                   echo "<script  type=\"text/javascript\">parent.left.location='left.php?dbsel=".$GLOBALS["dbsel"]."';</script>";
  132.             }
  133.             break;
  134.         case "export":
  135.             if($workDb->isReadable()) {
  136.                 include_once INCLUDE_LIB."SQLiteExport.class.php";
  137.                 $export =& new SQLiteExport($workDb);            
  138.             }
  139.             break;
  140.         case "del":
  141.             $query = "DELETE FROM database WHERE id=".$dbsel.";";
  142.             if($dbsel) {
  143.                 $db->query($query);
  144.                 // Remove attached databases
  145.                 $db->query("DELETE FROM attachment WHERE base_id=".$dbsel." OR attach_id=".$dbsel.";");                
  146.             }                
  147.             $redirect = "<script  type=\"text/javascript\">parent.location='index.php';</script>";
  148.             break;
  149.         case "add_view":
  150.             if($workDb->isReadable()) {
  151.                 $action = "add";
  152.                 include_once INCLUDE_LIB."viewproperties.php";
  153.             }                
  154.             break;
  155.         case "add_trigger":
  156.             if($workDb->isReadable()) {
  157.                 $action = "add";
  158.                 include_once INCLUDE_LIB."triggerproperties.php";
  159.             }
  160.             break;
  161.         case "add_function":
  162.             if($workDb->isReadable()) {
  163.                 $action = "add";
  164.                 include_once INCLUDE_LIB."functproperties.php";
  165.             }
  166.             break;
  167.         case "options":
  168.             if($workDb->isReadable()) {
  169.                 include_once INCLUDE_LIB."SQLiteDbOption.class.php";
  170.                 $Option =& new SQLiteDbOption($workDb);
  171.                 if ($_SERVER['REQUEST_METHOD'] == 'POST' || (isset($_REQUEST['attach_action']) && $_REQUEST['attach_action']=='del'))
  172.                   echo "<script  type=\"text/javascript\">parent.left.location='left.php?dbsel=".$GLOBALS["dbsel"]."';</script>";            
  173.             }
  174.             break;
  175.     }
  176.     
  177. } elseif(isset($GLOBALS["action"]) && ($GLOBALS["action"]=="auth")){
  178.     displayHeader("main");
  179.     $SQLiteManagerAuth->manageAuth();
  180. }
  181.  
  182. if(isset($redirect) && !empty($redirect)){
  183.         ob_end_clean();
  184.         echo $redirect;
  185. }
  186. @ob_end_flush();
  187. ?>
  188.