]> dev.renevier.net Git - syp.git/blob - inc/templates_upgrade.php
fixes: upgrade did not run correctly when gd extension is not present
[syp.git] / inc / templates_upgrade.php
1 <?php
2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
3    license. */
4 ?>
5 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
6        "http://www.w3.org/TR/html4/loose.dtd">  
7 <html lang="<?php echo $lang?>">
8 <head>
9       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
10       <link rel="stylesheet" href="./media/common.css" type="text/css" />
11       <title><?php ptrans ('SYP upgrade')?></title>
12 </head>
13 <body>
14 <?php
15     function create_all_thumbs($con) {
16         $features = $con->listfeatures ();
17         foreach ($features as $feature) {
18             if ($feature->imgpath) {
19                 $imgfilename = UPLOADDIR . "/" . $feature->imgpath;
20                 $thumbfilename = getthumbsdir () .  "/mini_" . $feature->imgpath;
21                 if ((file_exists ($imgfilename)) && 
22                     (!(file_exists ($thumbfilename)))) {
23                         create_thumbnail_or_copy ($imgfilename, $thumbfilename);
24                 }
25             }
26         }
27         return true;
28     }
29
30     require_once ("./inc/settings.php");
31     require_once ("./inc/db/mysql.php");
32     require_once ("./inc/utils.php");
33
34     $error = false;
35     try {
36         $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
37         $usrtblexists = $connection->users_table_exists ();
38         $itemstblexists = $connection->items_table_exists ();
39     } catch (Exception $e) {
40         $error = true;
41     }
42     if (!$usrtblexists || !$itemstblexists) {
43         $error = true;
44     }
45     if ($error) {
46        die(sprintf('<p class="error center">%s</p>', trans('SYP is not correctly installed. Please follow README.txt instructions
47        and go to <a href="wizard.en.php">wizard</a>.')));
48     }
49
50     safe_create_writable_dir (getthumbsdir ());
51     if (create_all_thumbs ($connection)) {
52         par_success (trans('Thumbnails successfully created.'));
53     } else {
54         par_error (trans('Error when creating thumbnails.'));
55     }
56
57     par_success (trans ('SYP upgrade went smoothly. You can now go to <a href="admin.en.php">admin area</a>'));
58
59 ?>
60 </body>
61 </html>