[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/setup/ -> upgrade_articleimg.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 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  require_once ('../config/phpwcms/conf.inc.php');
  26  require_once  ('../include/inc_lib/default.inc.php');
  27  require_once  (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php');
  28  require_once  (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php');
  29  require_once  (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php');
  30  
  31  ?>
  32  <html>
  33  <body>
  34  <h3>Upgrade article summary image for article</h3>
  35  <?php
  36  
  37  // get all articles
  38  if($all = _dbQuery("SELECT article_id, article_image, article_title, article_tstamp FROM ".DB_PREPEND."phpwcms_article")) {
  39  
  40      foreach($all as $key => $value) {
  41  
  42          $all[$key]['article_image']    = unserialize($all[$key]['article_image']);
  43          if(isset($all[$key]['article_image']['prev']) && !empty($all[$key]['article_image']['id'])) {
  44          
  45              //dumpVar($all[$key]);
  46          
  47              unset($all[$key]['article_image']['prev']);
  48              unset($all[$key]['article_image']['prev_info']);
  49              unset($all[$key]['article_image']['prev_make']);
  50              unset($all[$key]['article_image']['add']);
  51              unset($all[$key]['article_image']['cname']);
  52              
  53              $all[$key]['article_image']['id'] = intval($all[$key]['article_image']['id']);
  54              
  55              // retrieve image information
  56              $file = _dbQuery("SELECT f_id, f_hash, f_ext FROM ".DB_PREPEND."phpwcms_file WHERE f_id=".$all[$key]['article_image']['id']." LIMIT 1");
  57              
  58              if(!empty($file[0]['f_id']) && $file[0]['f_id'] == $all[$key]['article_image']['id']) {
  59                  $all[$key]['article_image']['hash']                = $file[0]['f_hash'];
  60                  $all[$key]['article_image']['ext']                = $file[0]['f_ext'];
  61                  $all[$key]['article_image']['list_usesummary']    = 1;
  62                  
  63                  $sql  = "UPDATE ".DB_PREPEND."phpwcms_article SET ";
  64                  $sql .= "article_image = '".aporeplace(serialize($all[$key]['article_image']))."',";
  65                  $sql .= "article_tstamp = '".$all[$key]['article_tstamp']."' WHERE article_id = ".$all[$key]['article_id']." LIMIT 1";
  66                  
  67                  $result = _dbQuery($sql, 'UPDATE');
  68                  
  69                  echo '<pre';
  70                  if($result === false) {
  71                      echo ' style="color:#CC3300"';
  72                  }
  73                  echo '>[ID:'.sprintf('%04s', $all[$key]['article_id']).'] '.html_specialchars($all[$key]['article_title']);
  74                  echo '</pre>'.LF;
  75                  
  76              }
  77          
  78          } else {
  79              
  80              unset($all[$key]);
  81  
  82          }
  83  
  84      }
  85  
  86  }
  87  ?>
  88  
  89  <p><strong>Done!</strong> All articles not listed here are not touched.</p>
  90  </body>
  91  </html>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7