source: extensions/GuestBook/include/import_tool.php @ 24889

Revision 24889, 1.5 KB checked in by mistic100, 6 years ago (diff)

use my plugin architecture, add options to hide the page for guests, fix admin links in mails

Line 
1<?php
2define('PHPWG_ROOT_PATH','../../../');
3include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
4
5if (!is_admin()) die('Access denied');
6?>
7<!DOCTYPE html>
8<html lang="en" dir="ltr">
9<head>
10  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
11  <title>GuestBook import</title>
12 
13  <style>
14    h3 { color:red; }
15  </style>
16</head>
17
18<body>
19<h2>GuestBook import</h2>
20
21<?php
22$show_form = true;
23
24if (isset($_POST['image_id']))
25{
26  if (!preg_match('#^[0-9]+$#', $_POST['image_id']))
27  {
28    echo '<h3>Incorrect image Id</h3><br>';
29  }
30  else
31  {
32    $query = '
33SELECT * FROM '.COMMENTS_TABLE.'
34  WHERE image_id = '.$_POST['image_id'].'
35;';
36    $comms = hash_from_query($query, 'id');
37   
38    if (!count($comms))
39    {
40      echo '<h3>No comments for this picture</h3><br>';
41    }
42    else
43    {
44      mass_inserts(
45        GUESTBOOK_TABLE,
46        array('date', 'author', 'author_id', 'anonymous_id', 'email', 'website', 'content', 'rate', 'validated', 'validation_date'),
47        $comms
48        );
49       
50      echo '<h3>'.count($comms).' comments imported into the Guestbook</h3><br>';
51      $show_form = false;
52    }
53  }
54}
55
56if ($show_form)
57{
58?>
59Just enter the ID of your old guestbook picture (the ID can be found a the picture edition page, near the thumbnail) and click the <b>import</b> button.
60<form action="" method="post">
61<label>Image ID : <input type="text" size="5" name="image_id"></label><br>
62<input type="submit" value="import">
63</form>
64
65<?php
66}
67?>
68
69<br>
70<a href="<?php echo GUESTBOOK_ADMIN; ?>-config">Go back</a>
71
72</body>
73</html>
Note: See TracBrowser for help on using the repository browser.