Changeset 555 for trunk/plog-admin/_upgrade.php
- Timestamp:
- 07/07/08 17:22:49 (5 months ago)
- Files:
-
- 1 modified
-
trunk/plog-admin/_upgrade.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plog-admin/_upgrade.php
r551 r555 1 1 <?php 2 2 error_reporting(E_ERROR); 3 echo ' 4 <html> 5 <head> 6 <title>Upgrade Plogger</title> 7 <link rel="stylesheet" type="text/css" href="css/admin.css"> 8 </head> 9 <body> 10 <img src="images/plogger.gif" alt="Plogger"> 11 <h1>Performing Upgrade...</h1>'; 12 3 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 5 <html xmlns="http://www.w3.org/1999/xhtml"> 6 <head> 7 <title>Upgrade Plogger</title> 8 <link rel="stylesheet" type="text/css" href="css/admin.css"> 9 </head> 10 11 <body> 12 13 <div><img src="images/plogger.gif" alt="Plogger" /></div> 14 15 <h1>Performing Upgrade...</h1>'; 16 13 17 // This is the upgrade file for upgrading your Plogger gallery from Beta 1 14 18 $workdir = dirname(dirname(__FILE__)); 15 19 if (file_exists($workdir.'/plog-connect.php')) 16 20 { 17 print "Rewriting configuration files...<br />";21 print "Rewriting configuration files...<br />"; 18 22 // this check will also make sure that we can delete plog-connect when done, since deleting 19 23 // is actually _writing_ to a directory … … 61 65 function makeDirs($strPath, $mode = 0777) //creates directory tree recursively 62 66 { 63 return is_dir($strPath) or ( makeDirs(dirname($strPath), $mode) and mkdir($strPath, $mode) );67 return is_dir($strPath) or ( makeDirs(dirname($strPath), $mode) and mkdir($strPath, $mode) ); 64 68 } 65 69 … … 91 95 mysql_query($sql); 92 96 } else { 93 //print "$column does not exist<br />";97 //print "$column does not exist<br />"; 94 98 } 95 99 } … … 186 190 maybe_drop_column($config_table,"rss_thumbsize"); 187 191 188 189 192 maybe_add_column($config_table,'gallery_url',"varchar(255) NOT NULL"); 190 193 … … 195 198 mysql_query($sql); 196 199 } 197 198 200 199 201 // RSS config … … 214 216 // 215 217 maybe_add_column($config_table,'allow_fullpic',"tinyint NOT NULL default '1'"); 216 218 217 219 // comment notify 218 220 maybe_add_column($config_table,'comments_notify',"tinyint NOT NULL"); … … 231 233 maybe_add_column(TABLE_PREFIX.'albums','path',"varchar(255) NOT NULL"); 232 234 maybe_add_column(TABLE_PREFIX.'collections','path',"varchar(255) NOT NULL"); 233 234 235 235 236 // add ip and approved fields to comments table … … 277 278 echo("<p>Database has already been upgraded to support smart thumbnail caching!</p>"); 278 279 */ 279 280 280 281 echo "</ul>"; 281 282 echo "<p>Reorganizing your 'images/' folder..."; … … 290 291 $sql = "UPDATE ".TABLE_PREFIX."collections SET path = '" . strtolower(sanitize_filename($row['name'])) . "' WHERE id = " . $row['id']; 291 292 #print $sql; 292 #print "<br />";293 #print "<br />"; 293 294 mysql_query($sql); 294 } 295 } 295 296 296 297 $sql = "SELECT id,name FROM ".TABLE_PREFIX."albums"; … … 299 300 $sql = "UPDATE ".TABLE_PREFIX."albums SET path = '" . strtolower(sanitize_filename($row['name'])) . "' WHERE id = " . $row['id']; 300 301 #print $sql; 301 #print "<br />";302 #print "<br />"; 302 303 mysql_query($sql); 303 } 304 } 304 305 305 306 // loop through each image from the pictures table, get its parent album name and parent collection … … 311 312 FROM ".TABLE_PREFIX."albums a, ".TABLE_PREFIX."pictures p, ".TABLE_PREFIX."collections c 312 313 WHERE p.parent_album = a.id AND p.parent_collection = c.id"; 313 314 314 315 315 $result = mysql_query($sql) or die(mysql_error() . "<br /><br />" . $sql); 316 316 317 318 317 echo "<ul>"; 319 318 320 319 while($row = mysql_fetch_assoc($result)) { 321 320 322 321 $errors = 0; 323 322 $filename = basename($row['path']); … … 325 324 $new_path = "plog-content/images/".$directory.$filename; 326 325 if ($row['path'] == $new_path) continue; 327 echo "<li>Moving $row[path] -> $new_path</li>";328 326 echo "<li>Moving $row[path] -> $new_path</li>"; 327 329 328 // move physical file, create directory if necessary and update path in database 330 329 if (!makeDirs("plog-content/images/".$directory, 0755)) 331 echo "<ul><li>Error: Could not create directory $directory!</li></ul>";332 330 echo "<ul><li>Error: Could not create directory $directory!</li></ul>"; 331 333 332 if (!rename("images/" . $row['path'], $new_path)) { 334 333 echo "<li>Error: could not move file!</li>"; 335 334 $errors++; 336 335 } 337 else { 336 else { 338 337 $directory = mysql_real_escape_string($directory . $filename); 339 338 // update database … … 341 340 mysql_query($sql) or die("<li>Error: ".mysql_error()." in query " . $sql . "</li>"); 342 341 } 343 344 } 345 342 343 } 344 346 345 echo "</ul>"; 347 346 … … 351 350 echo "There were $errors errors, check your permissions settings."; 352 351 } 353 354 355 356 352 357 353 // convert charsets … … 366 362 { 367 363 $charset = "utf8"; 368 print "<br />";364 print "<br />"; 369 365 $tables = array("collections","albums","pictures","comments","config"); 370 366 foreach($tables as $table) { … … 372 368 $sql = "ALTER TABLE $tablename DEFAULT CHARACTER SET $charset"; 373 369 if (mysql_query($sql)) { 374 print $tablename . " converted to $charset<br />";370 print $tablename . " converted to $charset<br />"; 375 371 } else { 376 print "failed to convert $tablename to $charset<br />";372 print "failed to convert $tablename to $charset<br />"; 377 373 print mysql_error(); 378 374 } … … 380 376 } 381 377 382 echo "<p>Upgrade has completed!</p>" 378 echo "<p>Upgrade has completed!</p> 379 380 </body> 381 </html>" 383 382 ?>
