]> dev.renevier.net Git - syp.git/blob - inc/templates_upgrade.php
1a69b68584b159af5e4a15d13fdf9aa49a3e3bea
[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                     try {
24                         create_thumbnail ($imgfilename, $thumbfilename);
25                     } catch (Exception $e) {
26                         return false;
27                     }
28                 }
29             }
30         }
31         return true;
32     }
33
34     require_once ("./inc/settings.php");
35     require_once ("./inc/db/mysql.php");
36     require_once ("./inc/utils.php");
37
38     $error = false;
39     try {
40         $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
41         $usrtblexists = $connection->users_table_exists ();
42         $itemstblexists = $connection->items_table_exists ();
43     } catch (Exception $e) {
44         $error = true;
45     }
46     if (!$usrtblexists || !$itemstblexists) {
47         $error = true;
48     }
49     if ($error) {
50        die(sprintf('<p class="error center">%s</p>', trans('SYP is not correctly installed. Please follow README.txt instructions
51        and go to <a href="wizard.en.php">wizard</a>.')));
52     }
53
54     safe_create_writable_dir (getthumbsdir ());
55     if (create_all_thumbs ($connection)) {
56         par_success (trans('Thumbnails successfully created.'));
57     } else {
58         par_error (trans('Error when creating thumbnails.'));
59     }
60
61     par_success (trans ('SYP upgrade went smoothly. You can now go to <a href="admin.en.php">admin area</a>'));
62
63 ?>
64 </body>
65 </html>