display_create_table.lib.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Displays form for creating a table (if user has privileges for that)
  5. *
  6. * for MySQL >= 4.1.0, we should be able to detect if user has a CREATE
  7. * privilege by looking at SHOW GRANTS output;
  8. * for < 4.1.0, it could be more difficult because the logic tries to
  9. * detect the current host and it might be expressed in many ways; also
  10. * on a shared server, the user might be unable to define a controluser
  11. * that has the proper rights to the "mysql" db;
  12. * so we give up and assume that user has the right to create a table
  13. *
  14. * Note: in this case we could even skip the following "foreach" logic
  15. *
  16. * Addendum, 2006-01-19: ok, I give up. We got some reports about servers
  17. * where the hostname field in mysql.user is not the same as the one
  18. * in mysql.db for a user. In this case, SHOW GRANTS does not return
  19. * the db-specific privileges. And probably, those users are on a shared
  20. * server, so can't set up a control user with rights to the "mysql" db.
  21. * We cannot reliably detect the db-specific privileges, so no more
  22. * warnings about the lack of privileges for CREATE TABLE. Tested
  23. * on MySQL 5.0.18.
  24. *
  25. * @package PhpMyAdmin
  26. */
  27. if (! defined('PHPMYADMIN')) {
  28. exit;
  29. }
  30. /**
  31. *
  32. */
  33. require_once './libraries/check_user_privileges.lib.php';
  34. $is_create_table_priv = true;
  35. ?>
  36. <form id="create_table_form_minimal" method="post" action="tbl_create.php">
  37. <fieldset>
  38. <legend>
  39. <?php
  40. if (in_array(
  41. $GLOBALS['cfg']['ActionLinksMode'],
  42. array('icons', 'both')
  43. )
  44. ) {
  45. echo PMA_Util::getImage('b_newtbl.png');
  46. }
  47. echo __('Create table');
  48. ?>
  49. </legend>
  50. <?php echo PMA_generate_common_hidden_inputs($db); ?>
  51. <div class="formelement">
  52. <?php echo __('Name'); ?>:
  53. <input type="text" name="table" maxlength="64" size="30" />
  54. </div>
  55. <div class="formelement">
  56. <?php echo __('Number of columns'); ?>:
  57. <input type="text" name="num_fields" size="2" />
  58. </div>
  59. <div class="clearfloat"></div>
  60. </fieldset>
  61. <fieldset class="tblFooters">
  62. <input type="submit" value="<?php echo __('Go'); ?>" />
  63. </fieldset>
  64. </form>