Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, March 29, 2024

Diff for phpMyEdit/phpMyEditSetup.php between version 1.3 and 1.4

version 1.3, 2002/08/07 22:13:30 version 1.4, 2002/08/09 23:18:48
Line 1 
Line 1 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <html>  <html>
 <head>  <head>
   <title>phpMyEdit Setup</title>          <title>phpMyEdit Setup</title>
 </head>  </head>
 <style type="text/css">  <style type="text/css">
   body {font-family: "Verdana", "Arial", "Sans-Serif"; text-align: left}          body  { font-family: "Verdana", "Arial", "Sans-Serif"; text-align: left }
   h1 {color: #004d9c; font-size: 12pt; font-weight: bold}          h1    { color: #004d9c; font-size: 12pt; font-weight: bold }
   h2 {color: #004d9c; font-size: 10pt; font-weight: bold}          h2    { color: #004d9c; font-size: 10pt; font-weight: bold }
   h3 {color: #004d9c; font-size: 10pt; }          h3    { color: #004d9c; font-size: 10pt; }
   p  {color: #004d9c; font-size: 8pt; }          p     { color: #004d9c; font-size: 8pt; }
   table {border: 2px solid #004d9c; font-size: 8pt; text-align: center; border-collapse: "collapse"; }          table { border: 2px solid #004d9c; font-size: 8pt; text-align: center; border-collapse: "collapse"; }
   td {border: 2px solid; padding: 2px; color: #004d9c; font-size: 8pt; }          td    { border: 2px solid; padding: 2px; color: #004d9c; font-size: 8pt; }
 </style>  </style>
 <body>  <body bgcolor=white>
 <?php  <?php
 // -- setup.php version 3.5 27-Apr-01  // -- setup.php version 3.5 27-Apr-01
   // Heavily updated by Ondrej Jombik in 9-Aug-2002.
   
   $pageTitle    = $HTTP_POST_VARS['pageTitle'];
   $baseFilename = $HTTP_POST_VARS['baseFilename'];
   $submit       = $HTTP_POST_VARS['submit'];
   $hn           = $HTTP_POST_VARS['hn'];
   $un           = $HTTP_POST_VARS['un'];
   $pw           = $HTTP_POST_VARS['pw'];
   $db           = $HTTP_POST_VARS['db'];
   $tb           = $HTTP_POST_VARS['tb'];
   $id           = $HTTP_POST_VARS['id'];
   
 $phpExtension = '.phtml';  $phpExtension = '.phtml';
 $phpExtension = '.php';  $phpExtension = '.php';
Line 24  $destDir = '.';
Line 35  $destDir = '.';
 $inclDir = '.';  $inclDir = '.';
 $headerFile = 'SiteHeader.inc';  $headerFile = 'SiteHeader.inc';
 $footerFile = 'SiteFooter.inc';  $footerFile = 'SiteFooter.inc';
 if (isset($baseFilename)) {  if (isset($baseFilename) && $baseFilename != '') {
         $phpFile = $baseFilename.$phpExtension;          $phpFile = $baseFilename.$phpExtension;
         //$contentFile = $baseFilename.'Content.inc';          //$contentFile = $baseFilename.'Content.inc';
         $contentFile = $baseFilename.'.php';          $contentFile = $baseFilename.'.php';
Line 49  function echo_buffer($x) {
Line 60  function echo_buffer($x) {
         $buffer .= $x."\n";          $buffer .= $x."\n";
 }  }
   
 $self = basename($PHP_SELF);  $self   = basename($HTTP_SERVER_VARS['PHP_SELF']);
 $dbl = @mysql_pconnect($hn,$un,$pw);  $dbl    = @mysql_pconnect($hn,$un,$pw);
 if ((!$dbl) or empty($submit))  
 {  if ((!$dbl) or empty($submit)) {
         echo '  <h1>Please log in to your MySQL database</h1>';          echo '  <h1>Please log in to your MySQL database</h1>';
         if (!empty($submit)) {echo '  <h2>Sorry - login failed - please try again</h2>'."\n";}          if (!empty($submit)) {echo '  <h2>Sorry - login failed - please try again</h2>'."\n";}
   echo '    echo '
Line 73  if ((!$dbl) or empty($submit))
Line 84  if ((!$dbl) or empty($submit))
     <input type="submit" name="submit" value="Submit">      <input type="submit" name="submit" value="Submit">
   </form>'."\n";    </form>'."\n";
 } else {  } else {
   if (!isset($db))    if (!isset($db)) {
   {  
     $dbs = mysql_list_dbs($dbl);      $dbs = mysql_list_dbs($dbl);
     $num_dbs = mysql_numrows($dbs);      $num_dbs = mysql_numrows($dbs);
     echo '  <h1>Please choose a database</h1>      echo '  <h1>Please choose a database</h1>
Line 83  if ((!$dbl) or empty($submit))
Line 93  if ((!$dbl) or empty($submit))
     <input type="hidden" name="un" value="'.$un.'">      <input type="hidden" name="un" value="'.$un.'">
     <input type="hidden" name="pw" value="'.$pw.'">      <input type="hidden" name="pw" value="'.$pw.'">
     <table border="1" cellpadding="1" cellspacing="1" summary="Choose Database">'."\n";      <table border="1" cellpadding="1" cellspacing="1" summary="Choose Database">'."\n";
       for ($i=0; $i<$num_dbs; $i++)          for ($i=0; $i<$num_dbs; $i++) {
       {                  $db = mysql_dbname($dbs, $i);
         $db = mysql_dbname($dbs, $i);                  if ($i==0) {
                         if ($i==0)                          echo '      <tr><td><input checked type="radio" name="db" value="'.$db.'"></td><td>'.$db.'</td></tr>'."\n";
              {echo '      <tr><td><input checked type="radio" name="db" value="'.$db.'"></td><td>'.$db.'</td></tr>'."\n"; }                  } else {
         else {echo '      <tr><td><input type="radio" name="db" value="'.$db.'"></td><td>'.$db.'</td></tr>'."\n";}                          echo '      <tr><td><input type="radio" name="db" value="'.$db.'"></td><td>'.$db.'</td></tr>'."\n";
       }                  }
           }
           echo '    </table>            echo '    </table>
     <br>      <br>
     <input type="submit" name="submit" value="Submit">      <input type="submit" name="submit" value="Submit">
     <input type="submit" name="cancel" value="Cancel">      <input type="submit" name="cancel" value="Cancel">
   </form>'."\n";    </form>'."\n";
   } else {    } else {
     if (!isset($tb))      if (!isset($tb)) {
     {  
       echo '  <h1>Please choose a table from database: '.$db.'</h1>        echo '  <h1>Please choose a table from database: '.$db.'</h1>
   <form action="'.$self.'" method="POST">    <form action="'.$self.'" method="POST">
     <input type="hidden" name="hn" value="'.$hn.'">      <input type="hidden" name="hn" value="'.$hn.'">
Line 106  if ((!$dbl) or empty($submit))
Line 116  if ((!$dbl) or empty($submit))
     <input type="hidden" name="db" value="'.$db.'">      <input type="hidden" name="db" value="'.$db.'">
     <table border="1" cellpadding="1" cellspacing="1" summary="Choose Table">'."\n";      <table border="1" cellpadding="1" cellspacing="1" summary="Choose Table">'."\n";
       $tbs = mysql_list_tables($db,$dbl);        $tbs = mysql_list_tables($db,$dbl);
       $num_tbs = @mysql_numrows($tbs);        $num_tbs = @mysql_num_rows($tbs);
       for ($j=0; $j<$num_tbs; $j++)        for ($j=0; $j<$num_tbs; $j++) {
       {  
         $tb = mysql_tablename($tbs, $j);          $tb = mysql_tablename($tbs, $j);
                         if ($j==0)                          if ($j == 0) {
              {echo '      <tr><td><input checked type="radio" name="tb" value="'.$tb.'"></td><td>'.$tb.'</td></tr>'."\n"; }                                  echo '      <tr><td><input checked type="radio" name="tb" value="'.$tb.'"></td><td>'.$tb.'</td></tr>'."\n";
         else {echo '      <tr><td><input type="radio" name="tb" value="'.$tb.'"></td><td>'.$tb.'</td></tr>'."\n";}                          } else {
                                   echo '      <tr><td><input type="radio" name="tb" value="'.$tb.'"></td><td>'.$tb.'</td></tr>'."\n";
                           }
       }        }
         echo '    </table>          echo '    </table>
     <br>      <br>
Line 120  if ((!$dbl) or empty($submit))
Line 131  if ((!$dbl) or empty($submit))
     <input type="submit" name="cancel" value="Cancel">      <input type="submit" name="cancel" value="Cancel">
   </form>'."\n";    </form>'."\n";
     } else  {      } else  {
       if (!isset($id))        if (!isset($id)) {
       {  
         echo '  <h1>Please choose an identifier from table: '.$tb.'</h1>          echo '  <h1>Please choose an identifier from table: '.$tb.'</h1>
   <h2>This field will be used in Changes or Deletes.</h2>    <h2>This field will be used in Changes or Deletes.</h2>
   <p>    <p>
Line 141  if ((!$dbl) or empty($submit))
Line 151  if ((!$dbl) or empty($submit))
                 mysql_select_db($db);                  mysql_select_db($db);
         $tb_desc = mysql_query("describe $tb");          $tb_desc = mysql_query("describe $tb");
         $fds = mysql_list_fields($db,$tb,$dbl);          $fds = mysql_list_fields($db,$tb,$dbl);
         $j=0;          $j   = 0;
         while (1)          while (1) {
                 {  
           $fd = @mysql_field_name($fds, $j);            $fd = @mysql_field_name($fds, $j);
           if ($fd == "") { break; }            if ($fd == "") { break; }
           $ff = mysql_field_flags($fds, $j);            $ff = mysql_field_flags($fds, $j);
                   echo "      <tr><td><input";                    echo '      <tr><td><input';
           if (stristr($ff,"primary_key"))                    if (stristr($ff, 'primary_key')) {
                echo ' checked';                            echo ' checked';
                     }
           echo ' type="radio" name="id" value="'.$fd.'"></td><td>'.$fd.'</td><td>'.$ff.'</td>';            echo ' type="radio" name="id" value="'.$fd.'"></td><td>'.$fd.'</td><td>'.$ff.'</td>';
                   $r = mysql_fetch_array($tb_desc,$j);                    $r = mysql_fetch_array($tb_desc,$j);
 /*  /*
Line 162  echo "</tr>\n";
Line 172  echo "</tr>\n";
         }          }
           echo '    </table>            echo '    </table>
     <br>      <br>
         Page Title: <input type="text" name=pageTitle value ="">          Page Title: <input type="text" name=pageTitle value ="'.$tb.'">
     <br>      <br>
         Base Filename: <input type="text" name=baseFilename value ="'.$tb.'">          Base Filename: <input type="text" name=baseFilename value ="'.$tb.'">
     <br>      <br>
Line 173  echo "</tr>\n";
Line 183  echo "</tr>\n";
       } else  {        } else  {
                         echo '<h1>Here is your phpMyEdit calling program</h1>'."\n";                          echo '<h1>Here is your phpMyEdit calling program</h1>'."\n";
                         echo '<h2>You may now copy and paste it into your PHP editor</h2>'."\n";                          echo '<h2>You may now copy and paste it into your PHP editor</h2>'."\n";
         echo '<hr><pre>'."\n";          //echo '<hr><pre>'."\n";
         echo_buffer('<div class="main">          echo_buffer('<div class="main">
   <h3><?php echo $_title; ?></h3>    <h3><?php echo \''.$pageTitle.'\'; ?></h3>
 <?php  <?php
 //   MySQL host name, user name, password, database, and table to edit  //   MySQL host name, user name, password, database, and table to edit'.
 # NOTE: coder is strongly urged to remove the hn, un, pw lines from  # NOTE: coder is strongly urged to remove the hn, un, pw lines from
 # here and set values in PME_site_defaults.inc  # here and set values in PME_site_defaults.inc
 #require "PME_site_defaults.inc";  #require "PME_site_defaults.inc";
   '
 $opts["hn"]="'.$hn.'";  $opts["hn"]="'.$hn.'";
 $opts["un"]="'.$un.'";  $opts["un"]="'.$un.'";
 $opts["pw"]="'.$pw.'";  $opts["pw"]="'.$pw.'";
Line 276  echo_buffer("
Line 287  echo_buffer("
                 or   ['values'] = range(1,99);                  or   ['values'] = range(1,99);
         ['values']['table'] and ['values']['column'] restricts user          ['values']['table'] and ['values']['column'] restricts user
                 input to the values found in the specified column of another table.                  input to the values found in the specified column of another table.
                 If the optional ['values']['description'] is also specified,                  The optional ['values']['description'] field allows the value(s) displayed
                 the values displayed to the user by phpMyEdit will be taken from the                  to the user to be different to those in the ['values']['column'] field.
                 column specified by 'description'. e.g.:                  This is useful for giving more meaning to column values.  There are two main
                   options when using the ['values']['description'] field. These are whether you
                   want to use a single, or multiple field in your description.  To apply single,
                   you need to use:
                           ['values']['description'] = 'desc_column'
                   This may be used, with no other options, and will simply display the description
                   for the corresponding value.
                   For Multiple, use:
                           ['values']['description']['columns']['1'] = 'desc_column_1'
                           ['values']['description']['divs']['1']    = ' '
                           ['values']['description']['columns']['2'] = 'desc_column_2'
                   The 'div' component is what will be used as a divider between the columns
                   in the display.  You don't need to define the last 'div' field if it isn't
                   required.  So, for example...if you have a series of people in a
                   table, with a separate column for id, first name, and last name, you could
                   use:
                         ['values']['db']='mydb' *optional if table is in another database*                          ['values']['db']='mydb' *optional if table is in another database*
                         ['values']['table']='mytable'                          ['values']['table']='mytable'
                         ['values']['column']='key_column'                          ['values']['column']='id'
                         ['values']['description']='result_column' *optional*                          ['values']['description']['columns']['1']='last_name'
                         ['values']['filters']='idcolumn in (1,,2,3)' *optional WHERE clause*                          ['values']['description']['divs']['1']   =', '
                         ['values']['orderby']='result_column' *optional ORDER BY clause*                          ['values']['description']['columns']['2']='first_name'
                           ['values']['filters']='idcolumn in (1,2,3)' *optional WHERE clause*
                           ['values']['orderby']='last_name' *optional ORDER BY clause*
                 if a column is either SET or ENUM type, then the values are put in                  if a column is either SET or ENUM type, then the values are put in
                 by PME Setup.                  by PME Setup.
         ['select'] = 'T/D/M' (text, drop-down, or multiple selection for filters)          ['select'] = 'T/D/M' (text, drop-down, or multiple selection for filters)
Line 319  echo_buffer("
Line 347  echo_buffer("
                         );                          );
           $row = mysql_fetch_array($tb_desc);            $row = mysql_fetch_array($tb_desc);
           echo_buffer('$fdd["'.$fd.'"] = array(');            echo_buffer('$fdd["'.$fd.'"] = array(');
                   echo_buffer(" 'name'=>'$fn',");                    echo_buffer(" 'name'=>'".str_replace('\'','\\\'',$fn)."',");
                   if (substr($row[1],0,3) == 'set') {                    if (substr($row[1],0,3) == 'set') {
                 echo_buffer("   'select'=>'M',");                  echo_buffer("   'select'=>'M',");
                 echo_buffer("   'type'=>'set',");                  echo_buffer("   'type'=>'set',");
Line 462  require_once 'phpMyEdit.class.php';
Line 490  require_once 'phpMyEdit.class.php';
  */   */
   
 if (0) {  if (0) {
 // write the php file          // write the php file
 $phpFileContents = '<?php          $phpFileContents = '<?php
 require \'PME_site_defaults.inc\';          require \'PME_site_defaults.inc\';
 $_title = "'.$pageTitle.'";          $_title = "'.$pageTitle.'";
 $_content = "'.$contentFile.'";          $_content = "'.$contentFile.'";
 include "'.$headerFile.'";          include "'.$headerFile.'";
 include $_content;          include $_content;
 include "'.$footerFile.'";          include "'.$footerFile.'";
 ?>';          ?>';
   
 echo 'Writing PHP file to: '.$destDir.'/'.$phpFile."<br>\n";          echo 'Writing PHP file to: '.$destDir.'/'.$phpFile."<br>\n";
 $filehandle = fopen($destDir.'/'.$phpFile,'w+');          $filehandle = @fopen($destDir.'/'.$phpFile,'w+');
   
 if ($filehandle) {          if ($filehandle) {
         fwrite($filehandle,$phpFileContents);                  fwrite($filehandle,$phpFileContents);
         flush($filehandle);                  flush($filehandle);
         fclose($filehandle);                  fclose($filehandle);
         echo "php file written successfully<br>";                  echo 'file written successfully<br>';
 }          }
 echo "<hr>PHP file:<pre>";          echo '<hr><b>PHP file:</b><pre>';
 echo_html($phpFileContents);          echo_html($phpFileContents);
 echo "</pre><hr>\n";          echo "</pre><hr>\n";
   
 } // if (0)  } // if (0)
   
 // write the content include file  // write the content include file
 echo 'Writing content file to: '.$inclDir.'/'.$contentFile."<br>\n";  echo 'Trying to write content file to: <b>'.$inclDir.'/'.$contentFile.'</b><br>'."\n";
 $filehandle = fopen($inclDir.'/'.$contentFile,'w+');  $filehandle = @fopen($inclDir.'/'.$contentFile,'w+');
 if ($filehandle) {  if ($filehandle) {
         fwrite($filehandle,$buffer);          fwrite($filehandle,$buffer);
         flush($filehandle);          flush($filehandle);
         fclose($filehandle);          fclose($filehandle);
         echo "include file written successfully<br>";          echo 'phpMyEdit content file written successfully<br>';
   } else {
           echo 'phpMyEdit content file was NOT written due to inssufficient privileges.<br>';
           echo 'Please copy and paste content listed below to <i>'.$inclDir.'/'.$contentFile.'</i> file.';
 }  }
 echo "<hr>PHP file:<pre>";  echo '<br><hr>';
   echo '<h2>phpMyEdit content file follows</h2>'."\n";
   echo '<pre>';
 echo_html($buffer);  echo_html($buffer);
 echo "</pre><hr>\n";  echo '</pre><hr>'."\n";
   
       }        }
     }      }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top