[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/setup/ -> upgrade_articlealias.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  //used to convert old style file uploads
  24  
  25  $phpwcms = array();
  26  
  27  require_once ('../config/phpwcms/conf.inc.php');
  28  require_once  ('../include/inc_lib/default.inc.php');
  29  require_once  (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php');
  30  require_once  (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php');
  31  require_once  (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php');
  32  
  33  ?>
  34  <html>
  35  <body>
  36  <h3>Upgrade article alias</h3>
  37  <?php
  38  
  39  // get all articles
  40  if($all = _dbQuery("SELECT article_id, article_alias, article_title FROM ".DB_PREPEND."phpwcms_article")) {
  41  
  42      foreach($all as $key => $value) {
  43  
  44          $alias = empty($value['article_alias']) ? $value['article_title'] : $value['article_alias'];
  45          $alias = proof_alias($value['article_id'], $alias, 'ARTICLE');
  46          
  47          if($alias != $value['article_alias']) {
  48          
  49              $sql  = "UPDATE ".DB_PREPEND."phpwcms_article SET ";
  50              $sql .= "article_alias = '".aporeplace($alias)."' ";
  51              $sql .= "WHERE article_id = ".$value['article_id']." LIMIT 1";
  52              
  53              $result = _dbQuery($sql, 'UPDATE');
  54              
  55              echo '<pre';
  56              if($result === false) {
  57                  echo ' style="color:#CC3300"';
  58              }
  59              echo '>[ID:'.sprintf('%04s', $all[$key]['article_id']).'] '.html_specialchars($value['article_title'].' -> new: ' . $alias);
  60              echo '</pre>'.LF;
  61          }
  62  
  63      }
  64  
  65  }
  66  ?>
  67  
  68  <p><strong>Done!</strong> All articles not listed here are not touched.</p>
  69  </body>
  70  </html>


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1