Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/upgrade-1.0-to-1.2.php,v $
15
  $Revision: 1.7 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:11 $
18
**********************************************/
19
 
20
define('IN_COPPERMINE', true);
21
define('ADMIN_PHP', true);
22
 
23
require "include/init.inc.php";
24
 
25
if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
26
 
27
$db10 = ""; // DB in which Coppermine 1.0 tables resides (leave blank is same DB as v1.2)
28
$prefix10 = "CPG_"; // The prefix used for the Coppermine 1.0 tables
29
$prefix10 = ($db10 ? $db10 . '.' : '') . $prefix10;
30
 
31
$CPG_pictures = $prefix10 . "pictures";
32
$CPG_albums = $prefix10 . "albums";
33
$CPG_comments = $prefix10 . "comments";
34
 
35
$cpg11_pictures = $CONFIG['TABLE_PICTURES'];
36
$cpg11_albums = $CONFIG['TABLE_ALBUMS'];
37
$cpg11_comments = $CONFIG['TABLE_COMMENTS'];
38
 
39
echo "Upgrading Coppermine 1.0 tables to 1.1<br />";
40
echo "Prefix used for 1.0 tables : $prefix10<br /><br />";
41
// Upgrade for the picture table
42
$sql = "INSERT INTO $cpg11_pictures " . "(approved, pid, aid, caption, filepath, filename, filesize, pwidth, pheight, hits, mtime," . " ctime) " . "SELECT 'yes' as approved, p.pid, aid, msg_body AS caption, filepath, filename, filesize, " . "pwidth, pheight, hits, mtime, UNIX_TIMESTAMP(ctime)" . "FROM $CPG_pictures AS p " . "LEFT JOIN $CPG_comments AS c ON p.caption = c.msg_id ";
43
db_query($sql);
44
echo "Picture table upgraded<br />";
45
// Get the list of comments that are used a image captions
46
$sql = "SELECT msg_id FROM $CPG_pictures AS p, $CPG_comments AS c " . "WHERE p.caption = c.msg_id";
47
$result = db_query($sql);
48
$msg_id_set = '';
49
if ((mysql_num_rows($result))) {
50
    $set = '';
51
    while ($comment = mysql_fetch_array($result)) {
52
        $set .= $comment['msg_id'] . ',';
53
    } // while
54
    $msg_id_set = 'AND msg_id NOT IN (' . substr($set, 0, -1) . ') ';
55
}
56
mysql_free_result($result);
57
// Upgrade the comment table
58
$sql = "INSERT INTO $cpg11_comments " . "(pid, msg_id, msg_author, msg_body, msg_date)" . "SELECT pid, msg_id, msg_author, msg_body, msg_date " . "FROM $CPG_comments " . "WHERE 1 $msg_id_set";
59
db_query($sql);
60
echo "Comment table upgraded<br />";
61
// Upgrade the album table
62
$sql = "INSERT INTO $cpg11_albums " . "(aid, title, description, uploads, pos)" . "SELECT aid, title, description, uploads, UNIX_TIMESTAMP(date) " . "FROM $CPG_albums";
63
db_query($sql);
64
echo "Album table upgraded<br />";
65
echo "<br />First step of upgrade completed!<br />";
66
 
67
echo "<a href='update.php'>Click Here</a> to complete the 1.2 upgrade.</P>";
68
 
69
?>