View file script/admin/upgrade.php

File size: 6.14Kb
<?php

if(isset($submit))
{
include 'conf.inc.php';
$connect = mysql_connect($host,$login,$pass);
mysql_select_db($base, $connect);


if (empty($date)) $date = date("Y-m-d");

$sql = "ALTER TABLE mcgallery_albumflash
ADD level CHAR( 1 ) NOT NULL ,
ADD comment CHAR( 1 ) NOT NULL ,
ADD ecard CHAR( 1 ) NOT NULL ,
ADD selection CHAR( 1 ) NOT NULL";

if(mysql_query($sql))
echo '4 fileds added to mcgallery_albumflash table<br>';

$sql = "UPDATE mcgallery_albumflash
SET level = 1, comment = 6, ecard = 3, selection = 2";

if(mysql_query($sql))
echo  mysql_affected_rows().' values modified in mcgallery_albumflash table<br>';

$sql = "ALTER TABLE mcgallery_albumvideo
ADD level CHAR( 1 ) NOT NULL ,
ADD comment CHAR( 1 ) NOT NULL ,
ADD ecard CHAR( 1 ) NOT NULL ,
ADD selection CHAR( 1 ) NOT NULL ";

if(mysql_query($sql))
echo '4 fileds added to mcgallery_albumvideo table<br>';

$sql = "UPDATE mcgallery_albumvideo
SET level = 1, comment = 6, ecard = 3, selection = 2";

if(mysql_query($sql))
echo  mysql_affected_rows().' values modified in mcgallery_albumvideo table<br>';

$sql = "ALTER TABLE mcgallery_albumphoto
ADD level CHAR( 1 ) NOT NULL ,
ADD comment CHAR( 1 ) NOT NULL ,
ADD ecard CHAR( 1 ) NOT NULL ,
ADD selection CHAR( 1 ) NOT NULL,
ADD upload CHAR( 1 ) NOT NULL ";

if(mysql_query($sql))
echo '5 fileds added to mcgallery_albumphoto table<br>';

$sql = "UPDATE mcgallery_albumphoto
SET level = 1, comment = 6, ecard = 3, selection = 2, upload = 3";

if(mysql_query($sql))
echo  mysql_affected_rows().' values modified in mcgallery_albumphoto table<br>';

$sql = "ALTER TABLE mcgallery_select
ADD id INT( 5 ) NOT NULL FIRST";

if(mysql_query($sql))
echo '1 filed added to  mcgallery_select table<br>';

$sql = "SELECT t.id, t.file FROM mcgallery_photo as t, mcgallery_select as s
WHERE t.file = s.file AND s.type = 'P'";
$res = mysql_query($sql);
$i = 0;
while ($row = mysql_fetch_row($res))
{
	$sql = "UPDATE mcgallery_select SET id = $row[0] WHERE file = '$row[1]'";
	mysql_query($sql);
	$i++;
}

$sql = "SELECT t.id, t.file FROM mcgallery_video as t, mcgallery_select as s
WHERE t.file = s.file AND s.type = 'V'";
$res = mysql_query($sql);
while ($row = mysql_fetch_row($res))
{
	$sql = "UPDATE mcgallery_select SET id = $row[0] WHERE file = '$row[1]'";
	mysql_query($sql);
	$i++;
}

$sql = "SELECT t.id, t.file FROM mcgallery_flash as t, mcgallery_select as s
WHERE t.file = s.file AND s.type = 'F'";
$res = mysql_query($sql);
while ($row = mysql_fetch_row($res))
{
	$sql = "UPDATE mcgallery_select SET id = $row[0] WHERE file = '$row[1]'";
	mysql_query($sql);
	$i++;
}

echo  $i.' values modified in mcgallery_select table<br>';

$sql = "ALTER TABLE mcgallery_card
CHANGE image image VARCHAR( 100 ) NOT NULL ";

if(mysql_query($sql))
echo '1 field modified in mcgallery_card table<br>';

$sql = "ALTER TABLE mcgallery_comment
CHANGE id id INT( 5 ) NOT NULL AUTO_INCREMENT,
CHANGE id_photo id_photo INT( 5 ) NOT NULL,
ADD note VARCHAR( 1 ) AFTER text";

if(mysql_query($sql))
echo ' 1 field added and 2 modified in mcgallery_comment table<br>';

$sql = "ALTER TABLE mcgallery_flash
ADD add_date DATE NOT NULL AFTER descr";

if(mysql_query($sql))
echo ' 1 field added to mcgallery_flash table<br>';

$sql = "UPDATE mcgallery_flash
SET add_date = '$date'";

if(mysql_query($sql))
echo mysql_affected_rows().' values modified in mcgallery_flash table<br>';

$sql = "ALTER TABLE mcgallery_video
ADD add_date DATE NOT NULL AFTER descr";

if(mysql_query($sql))
echo '1 field added to mcgallery_video table<br>';

$sql = "UPDATE mcgallery_video
SET add_date = '$date'";

if(mysql_query($sql))
echo mysql_affected_rows().' values modified in mcgallery_video table<br>';

$sql = "ALTER TABLE mcgallery_photo
ADD add_date DATE NOT NULL AFTER descr,
ADD watermark TINYINT( 1 ) DEFAULT '1' NOT NULL AFTER ref,
ADD string VARCHAR( 50 ) NOT NULL AFTER watermark";

if(mysql_query($sql))
echo ' 3 fields added to mcgallery_photo table<br>';

$sql = "UPDATE mcgallery_photo
SET add_date = '$date', watermark = 1";

if(mysql_query($sql))
echo mysql_affected_rows().' values modified in mcgallery_photo table<br>';

$sql = "UPDATE mcgallery_members
SET upload = '";

if(mysql_query($sql))
echo mysql_affected_rows().' values modified in mcgallery_members table<br>';

$sql = "ALTER TABLE mcgallery_members
CHANGE upload register DATE NOT NULL ";

if(mysql_query($sql))
echo '1 filed modified in mcgallery_members table<br>';

$sql = "UPDATE mcgallery_members
SET register = '$date'";

if(mysql_query($sql))
echo mysql_affected_rows().' values modified in mcgallery_members table<br>';

$sql="DROP TABLE mcgallery_design";
if(mysql_query($sql))
echo 'mcgallery_design table deleted<br>';
echo '<br>Go now to your admin section, by clicking on the link below, and click on Config to set all new options.<br>';
echo 'Then set all levels for all your albums, and check levels ofl your members.<br><br>';
echo '<br>Allez maintenant dans la section admin, en cliquant ci-dessous, et cliquez sur Config pour r&eacute;gler les options.<br>';
echo 'Ensuite r&eacute;glez les niveaux de tous vos albums, et v&eacute;rifiez ceux de vos membres.<br><br>';
echo '<br><a href="install.php">continue >></a>';
}
else
{
?>
<form method="post" action="upgrade.php">
<table align="center" border="0">
<tr>
<td>
Photos, Videos and Flash movies will have a "Date Added" field.<br>
Members will have a "Registered Date" field.<br>
Please fill the field on the right with the date you wish to set for all existing items<br>
(FORMAT MUST BE YYYY-MM-DD, i.e 2003-01-28 for instance)<br>
<hr>
Les Photos, Vid&eacute;os et Animations Flash auront une "Date d'Entr&eacute;e".<br>
Les Membres auront une "Date d'Inscription".<br>
Merci de renseigner le champ ci-contre avec la date que vous voulez appliquer &agrave tout l'existant.<br>
(LE FORMAT DOIT ETRE AAA-MM-JJ, soit 2003-01-28 par exemple)<br>
<hr>
</td>
</tr>
<tr>
<td>
DATE : <input type"text" name="date" value="<?php echo date("Y-m-d"); ?>">&nbsp;
<input type="submit" name="submit" value=" OK ">
</td>
</tr>
</table>
</form>
</table>
<?php
}
?>