[ Index ]
 

Code source de osCommerce 2.2ms2-060817

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/extras/pr21_to_pr22/ -> images.php (source)

   1  <?php
   2  /*
   3    $Id: images.php,v 1.3 2001/12/01 20:17:18 hpdl Exp $
   4  
   5    The Exchange Project - Community Made Shopping!
   6    http://www.theexchangeproject.org
   7  
   8    Copyright (c) 2000,2001 The Exchange Project
   9  
  10    Released under the GNU General Public License
  11  */
  12  
  13    if (!$HTTP_POST_VARS['DB_SERVER']) {
  14  ?>
  15  <html>
  16  <head>
  17  <title>The Exchange Project Preview Release 2.2 Database Update Script</title>
  18  <style type=text/css><!--
  19    TD, P, BODY {
  20      font-family: Verdana, Arial, sans-serif;
  21      font-size: 14px;
  22      color: #000000;
  23    }
  24  //--></style>
  25  </head>
  26  <body>
  27  <p>
  28  <b>The Exchange Project Preview Release 2.2 Database Update Script</b>
  29  <p>
  30  This script removes all hardcode occurences of 'images/' in the following tables:
  31  <p>
  32  categories.categories_image<br>
  33  manufacturers.manufacturers_image<br>
  34  products.products_image
  35  <p>
  36  <form name="database" action="<?php echo basename($PHP_SELF); ?>" method="post">
  37  <table border="0" cellspacing="2" cellpadding="2">
  38    <tr>
  39      <td colspan="2"><b>Database Server Information</b></td>
  40    </tr>
  41    <tr>
  42      <td>Server:</td>
  43      <td><input type="text" name="DB_SERVER"> <small>(eg, 192.168.0.1)</small></td>
  44    </tr>
  45    <tr>
  46      <td>Username:</td>
  47      <td><input type="text" name="DB_SERVER_USERNAME"> <small>(eg, root)</small></td>
  48    </tr>
  49    <tr>
  50      <td>Password:</td>
  51      <td><input type="text" name="DB_SERVER_PASSWORD"> <small>(eg, bee)</small></td>
  52    </tr>
  53    <tr>
  54      <td>Database:</td>
  55      <td><input type="text" name="DB_DATABASE"> <small>(eg, catalog)</small></td>
  56    </tr>
  57    <tr>
  58      <td>&nbsp;</td>
  59      <td><input type="submit" value="Submit"></td>
  60    </tr>
  61  </table>
  62  </form>
  63  </body>
  64  </html>
  65  <?php
  66      exit;
  67    }
  68  
  69    function tep_db_connect() {
  70      global $db_link, $HTTP_POST_VARS;
  71  
  72      $db_link = mysql_connect($HTTP_POST_VARS['DB_SERVER'], $HTTP_POST_VARS['DB_SERVER_USERNAME'], $HTTP_POST_VARS['DB_SERVER_PASSWORD']);
  73  
  74      if ($db_link) mysql_select_db($HTTP_POST_VARS['DB_DATABASE']);
  75  
  76      return $db_link;
  77    }
  78  
  79    function tep_db_error ($query, $errno, $error) { 
  80      die('<font color="#000000"><b>' . $errno . ' - ' . $error . '<br><br>' . $query . '<br><br><small><font color="#ff0000">[TEP STOP]</font></small><br><br></b></font>');
  81    }
  82  
  83    function tep_db_query($db_query) {
  84      global $db_link;
  85  
  86      $result = mysql_query($db_query, $db_link) or tep_db_error($db_query, mysql_errno(), mysql_error());
  87  
  88      return $result;
  89    }
  90  
  91    function tep_db_fetch_array($db_query) {
  92      $result = mysql_fetch_array($db_query);
  93  
  94      return $result;
  95    }
  96  
  97    tep_db_connect() or die('Unable to connect to database server!');
  98  
  99  // categories
 100    $categories_query = tep_db_query("select categories_id, categories_image from categories where left(categories_image, 7) = 'images/'");
 101    while ($categories = tep_db_fetch_array($categories_query)) {
 102      tep_db_query("update categories set categories_image = substring('" . $categories['categories_image'] . "', 8) where categories_id = '" . $categories['categories_id'] . "'");
 103    }
 104  
 105  // manufacturers
 106    $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_image from manufacturers where left(manufacturers_image, 7) = 'images/'");
 107    while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
 108      tep_db_query("update manufacturers set manufacturers_image = substring('" . $manufacturers['manufacturers_image'] . "', 8) where manufacturers_id = '" . $manufacturers['manufacturers_id'] . "'");
 109    }
 110  
 111  // products
 112    $products_query = tep_db_query("select products_id, products_image from products where left(products_image, 7) = 'images/'");
 113    while ($products = tep_db_fetch_array($products_query)) {
 114      tep_db_query("update products set products_image = substring('" . $products['products_image'] . "', 8) where products_id = '" . $products['products_id'] . "'");
 115    }
 116  ?>
 117  
 118  Done!


Généré le : Mon Nov 26 19:48:25 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics